multi: let ForEachChannel be a method on ChannelGraph
Having a `ForEachChannel` method on the `LightningNode` struct itself results in a `kvdb.Backend` object needing to be stored within the LightningNode struct. In this commit, this method is replaced with a `ForEachNodeChannel` method on the `ChannelGraph` struct will perform the same function without needing the db pointer to be stored within the LightningNode. This change, the LightningNode struct more closely represents the schema on disk. The existing `ForEachNodeChannel` method on `ChannelGraph` is renamed to `ForEachNodeDirectedChannel`. It performs a slightly different function since it's call-back operates on Cached policies.
This commit is contained in:
7 files changed
+207
-171
No files matched your search
+1
-1
@@ -75,7 +75,7 @@ func (g *CachedGraph) Close() error {
|
||||
func (g *CachedGraph) forEachNodeChannel(nodePub route.Vertex,
|
||||
cb func(channel *channeldb.DirectedChannel) error) error {
|
||||
|
||||
return g.graph.ForEachNodeChannel(g.tx, nodePub, cb)
|
||||
return g.graph.ForEachNodeDirectedChannel(g.tx, nodePub, cb)
|
||||
}
|
||||
|
||||
// sourceNode returns the source node of the graph.
|
||||
|
||||
+11
-8
@@ -2824,16 +2824,19 @@ func (r *ChannelRouter) ForEachNode(
|
||||
func (r *ChannelRouter) ForAllOutgoingChannels(cb func(kvdb.RTx,
|
||||
*channeldb.ChannelEdgeInfo, *channeldb.ChannelEdgePolicy) error) error {
|
||||
|
||||
return r.selfNode.ForEachChannel(nil, func(tx kvdb.RTx,
|
||||
c *channeldb.ChannelEdgeInfo,
|
||||
e, _ *channeldb.ChannelEdgePolicy) error {
|
||||
return r.cfg.Graph.ForEachNodeChannel(nil, r.selfNode.PubKeyBytes,
|
||||
func(tx kvdb.RTx, c *channeldb.ChannelEdgeInfo,
|
||||
e *channeldb.ChannelEdgePolicy,
|
||||
_ *channeldb.ChannelEdgePolicy) error {
|
||||
|
||||
if e == nil {
|
||||
return fmt.Errorf("channel from self node has no policy")
|
||||
}
|
||||
if e == nil {
|
||||
return fmt.Errorf("channel from self node " +
|
||||
"has no policy")
|
||||
}
|
||||
|
||||
return cb(tx, c, e)
|
||||
})
|
||||
return cb(tx, c, e)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// AddProof updates the channel edge info with proof which is needed to
|
||||
|
||||
Reference in new issue
Block a user