mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-20 13:53:19 +02:00
router+graph: return ErrGraphNodesNotFound if no nodes to prune
Avoids creating a bucket unneccessarily.
This commit is contained in:
parent
87df6b71c5
commit
81fe6e73ed
@ -795,9 +795,9 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
|
|||||||
// node gains more channels, it will be re-added back to the graph.
|
// node gains more channels, it will be re-added back to the graph.
|
||||||
func (c *ChannelGraph) PruneGraphNodes() error {
|
func (c *ChannelGraph) PruneGraphNodes() error {
|
||||||
return c.db.Update(func(tx *bbolt.Tx) error {
|
return c.db.Update(func(tx *bbolt.Tx) error {
|
||||||
nodes, err := tx.CreateBucketIfNotExists(nodeBucket)
|
nodes := tx.Bucket(nodeBucket)
|
||||||
if err != nil {
|
if nodes == nil {
|
||||||
return err
|
return ErrGraphNodesNotFound
|
||||||
}
|
}
|
||||||
edges := tx.Bucket(edgeBucket)
|
edges := tx.Bucket(edgeBucket)
|
||||||
if edges == nil {
|
if edges == nil {
|
||||||
|
@ -445,7 +445,8 @@ func (r *ChannelRouter) Start() error {
|
|||||||
// Finally, before we proceed, we'll prune any unconnected nodes from
|
// Finally, before we proceed, we'll prune any unconnected nodes from
|
||||||
// the graph in order to ensure we maintain a tight graph of "useful"
|
// the graph in order to ensure we maintain a tight graph of "useful"
|
||||||
// nodes.
|
// nodes.
|
||||||
if err := r.cfg.Graph.PruneGraphNodes(); err != nil {
|
err = r.cfg.Graph.PruneGraphNodes()
|
||||||
|
if err != nil && err != channeldb.ErrGraphNodesNotFound {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user