channeldb: return proper error in ChannelGraph.ForEachChannel()
This commit fixes a minor bug in the ForEachChannel method of the ChannelGraph struct. Rather than ErrGraphNoEdgesFound being returned if either of the edge related buckets hadn’t been created yet, ErrGraphNodesNotFound was being returned. To fix this bug, we now properly return ErrGraphNoEdgesFound. Additionally a mental note to roasbeef has been left as the current code currently assumes that eventually both directions of the channel edge will be advertised. However, this may not necessarily be the case in a live network, since a side chooses to preferentially advertise a channel or not.
This commit is contained in:
parent
4a0a657eb0
commit
42c90794ac
@ -131,11 +131,11 @@ func (c *ChannelGraph) ForEachChannel(cb func(*ChannelEdge, *ChannelEdge) error)
|
||||
// logically.
|
||||
edges := tx.Bucket(edgeBucket)
|
||||
if edges == nil {
|
||||
return ErrGraphNodesNotFound
|
||||
return ErrGraphNoEdgesFound
|
||||
}
|
||||
edgeIndex := edges.Bucket(edgeIndexBucket)
|
||||
if edgeIndex == nil {
|
||||
return ErrGraphNodesNotFound
|
||||
return ErrGraphNoEdgesFound
|
||||
}
|
||||
|
||||
// For each edge pair within the edge index, we fetch each edge
|
||||
@ -162,6 +162,10 @@ func (c *ChannelGraph) ForEachChannel(cb func(*ChannelEdge, *ChannelEdge) error)
|
||||
edge2.db = c.db
|
||||
edge2.Node.db = c.db
|
||||
|
||||
// TODO(roasbeef): second edge might not have
|
||||
// propagated through network yet (or possibly never
|
||||
// will be)
|
||||
|
||||
// With both edges read, execute the call back. IF this
|
||||
// function returns an error then the transaction will
|
||||
// be aborted.
|
||||
|
Loading…
Reference in New Issue
Block a user