From 5d8d99b7bcd553d19791f5bcb009a4a271edef50 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Tue, 4 Dec 2018 11:20:38 +0100 Subject: [PATCH] channeldb/graph: don't create bucket in UpdateChannelEdge It would return ErrEdgeNotFound when edge not found in bucket anyway. --- channeldb/graph.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/channeldb/graph.go b/channeldb/graph.go index 7cf7f898..6a7d496a 100644 --- a/channeldb/graph.go +++ b/channeldb/graph.go @@ -652,13 +652,14 @@ func (c *ChannelGraph) UpdateChannelEdge(edge *ChannelEdgeInfo) error { binary.BigEndian.PutUint64(chanKey[:], edge.ChannelID) return c.db.Update(func(tx *bbolt.Tx) error { - edges, err := tx.CreateBucketIfNotExists(edgeBucket) - if err != nil { - return err + edges := tx.Bucket(edgeBucket) + if edge == nil { + return ErrEdgeNotFound } - edgeIndex, err := edges.CreateBucketIfNotExists(edgeIndexBucket) - if err != nil { - return err + + edgeIndex := edges.Bucket(edgeIndexBucket) + if edgeIndex == nil { + return ErrEdgeNotFound } if edgeInfo := edgeIndex.Get(chanKey[:]); edgeInfo == nil {