router+graph: return ErrGraphNodesNotFound if no nodes to prune

Avoids creating a bucket unneccessarily.
This commit is contained in:
Johan T. Halseth committed 2018-12-06 10:22:15 +01:00
1 parent 87df6b71c5
commit 81fe6e73ed
2 files changed
+5 -4

No files matched your search

+3 -3
View File
@@ -795,9 +795,9 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
// node gains more channels, it will be re-added back to the graph.
func (c *ChannelGraph) PruneGraphNodes() error {
return c.db.Update(func(tx *bbolt.Tx) error {
nodes, err := tx.CreateBucketIfNotExists(nodeBucket)
if err != nil {
return err
nodes := tx.Bucket(nodeBucket)
if nodes == nil {
return ErrGraphNodesNotFound
}
edges := tx.Bucket(edgeBucket)
if edges == nil {