Revert "channeldb: convert all Update calls to use Batch"
This reverts commit 3555d3dbd431fe3ddf2660d4dc270b5a595fe517.
This commit is contained in:
parent
c37ea68ba6
commit
f6d93c8e5d
@ -334,7 +334,7 @@ func (c *ChannelGraph) sourceNode(nodes *bbolt.Bucket) (*LightningNode, error) {
|
||||
func (c *ChannelGraph) SetSourceNode(node *LightningNode) error {
|
||||
nodePubBytes := node.PubKeyBytes[:]
|
||||
|
||||
return c.db.Batch(func(tx *bbolt.Tx) error {
|
||||
return c.db.Update(func(tx *bbolt.Tx) error {
|
||||
// First grab the nodes bucket which stores the mapping from
|
||||
// pubKey to node information.
|
||||
nodes, err := tx.CreateBucketIfNotExists(nodeBucket)
|
||||
@ -363,7 +363,7 @@ func (c *ChannelGraph) SetSourceNode(node *LightningNode) error {
|
||||
//
|
||||
// TODO(roasbeef): also need sig of announcement
|
||||
func (c *ChannelGraph) AddLightningNode(node *LightningNode) error {
|
||||
return c.db.Batch(func(tx *bbolt.Tx) error {
|
||||
return c.db.Update(func(tx *bbolt.Tx) error {
|
||||
return addLightningNode(tx, node)
|
||||
})
|
||||
}
|
||||
@ -427,7 +427,7 @@ func (c *ChannelGraph) LookupAlias(pub *btcec.PublicKey) (string, error) {
|
||||
// from the database according to the node's public key.
|
||||
func (c *ChannelGraph) DeleteLightningNode(nodePub *btcec.PublicKey) error {
|
||||
// TODO(roasbeef): ensure dangling edges are removed...
|
||||
return c.db.Batch(func(tx *bbolt.Tx) error {
|
||||
return c.db.Update(func(tx *bbolt.Tx) error {
|
||||
nodes := tx.Bucket(nodeBucket)
|
||||
if nodes == nil {
|
||||
return ErrGraphNodeNotFound
|
||||
@ -491,7 +491,7 @@ func (c *ChannelGraph) deleteLightningNode(nodes *bbolt.Bucket,
|
||||
// the channel supports. The chanPoint and chanID are used to uniquely identify
|
||||
// the edge globally within the database.
|
||||
func (c *ChannelGraph) AddChannelEdge(edge *ChannelEdgeInfo) error {
|
||||
return c.db.Batch(func(tx *bbolt.Tx) error {
|
||||
return c.db.Update(func(tx *bbolt.Tx) error {
|
||||
return c.addChannelEdge(tx, edge)
|
||||
})
|
||||
}
|
||||
@ -675,7 +675,7 @@ func (c *ChannelGraph) UpdateChannelEdge(edge *ChannelEdgeInfo) error {
|
||||
var chanKey [8]byte
|
||||
binary.BigEndian.PutUint64(chanKey[:], edge.ChannelID)
|
||||
|
||||
return c.db.Batch(func(tx *bbolt.Tx) error {
|
||||
return c.db.Update(func(tx *bbolt.Tx) error {
|
||||
edges := tx.Bucket(edgeBucket)
|
||||
if edge == nil {
|
||||
return ErrEdgeNotFound
|
||||
@ -715,9 +715,7 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
|
||||
|
||||
var chansClosed []*ChannelEdgeInfo
|
||||
|
||||
err := c.db.Batch(func(tx *bbolt.Tx) error {
|
||||
chansClosed = nil
|
||||
|
||||
err := c.db.Update(func(tx *bbolt.Tx) error {
|
||||
// First grab the edges bucket which houses the information
|
||||
// we'd like to delete
|
||||
edges, err := tx.CreateBucketIfNotExists(edgeBucket)
|
||||
@ -826,7 +824,7 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
|
||||
// that we only maintain a graph of reachable nodes. In the event that a pruned
|
||||
// node gains more channels, it will be re-added back to the graph.
|
||||
func (c *ChannelGraph) PruneGraphNodes() error {
|
||||
return c.db.Batch(func(tx *bbolt.Tx) error {
|
||||
return c.db.Update(func(tx *bbolt.Tx) error {
|
||||
nodes := tx.Bucket(nodeBucket)
|
||||
if nodes == nil {
|
||||
return ErrGraphNodesNotFound
|
||||
@ -971,9 +969,7 @@ func (c *ChannelGraph) DisconnectBlockAtHeight(height uint32) ([]*ChannelEdgeInf
|
||||
// Keep track of the channels that are removed from the graph.
|
||||
var removedChans []*ChannelEdgeInfo
|
||||
|
||||
if err := c.db.Batch(func(tx *bbolt.Tx) error {
|
||||
removedChans = nil
|
||||
|
||||
if err := c.db.Update(func(tx *bbolt.Tx) error {
|
||||
edges, err := tx.CreateBucketIfNotExists(edgeBucket)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -1103,7 +1099,7 @@ func (c *ChannelGraph) DeleteChannelEdge(chanPoint *wire.OutPoint) error {
|
||||
// channels
|
||||
// TODO(roasbeef): don't delete both edges?
|
||||
|
||||
return c.db.Batch(func(tx *bbolt.Tx) error {
|
||||
return c.db.Update(func(tx *bbolt.Tx) error {
|
||||
// First grab the edges bucket which houses the information
|
||||
// we'd like to delete
|
||||
edges := tx.Bucket(edgeBucket)
|
||||
@ -1696,7 +1692,7 @@ func delChannelByEdge(edges, edgeIndex, chanIndex, zombieIndex,
|
||||
// determined by the lexicographical ordering of the identity public keys of
|
||||
// the nodes on either side of the channel.
|
||||
func (c *ChannelGraph) UpdateEdgePolicy(edge *ChannelEdgePolicy) error {
|
||||
return c.db.Batch(func(tx *bbolt.Tx) error {
|
||||
return c.db.Update(func(tx *bbolt.Tx) error {
|
||||
return updateEdgePolicy(tx, edge)
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user