mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-26 13:42:49 +02:00
graph/db: detach forEachNode from KVStore
So that we can use it in a context that only has access to a kvdb.Backend. We'll use this in our kvdb->SQL migration.
This commit is contained in:
@@ -658,7 +658,7 @@ func (c *KVStore) ForEachNodeCached(cb func(node route.Vertex,
|
||||
// We'll iterate over each node, then the set of channels for each
|
||||
// node, and construct a similar callback functiopn signature as the
|
||||
// main funcotin expects.
|
||||
return c.forEachNode(func(tx kvdb.RTx,
|
||||
return forEachNode(c.db, func(tx kvdb.RTx,
|
||||
node *models.LightningNode) error {
|
||||
|
||||
channels := make(map[uint64]*DirectedChannel)
|
||||
@@ -774,7 +774,7 @@ func (c *KVStore) DisabledChannelIDs() ([]uint64, error) {
|
||||
// executed under the same read transaction and so, methods on the NodeTx object
|
||||
// _MUST_ only be called from within the call-back.
|
||||
func (c *KVStore) ForEachNode(cb func(tx NodeRTx) error) error {
|
||||
return c.forEachNode(func(tx kvdb.RTx,
|
||||
return forEachNode(c.db, func(tx kvdb.RTx,
|
||||
node *models.LightningNode) error {
|
||||
|
||||
return cb(newChanGraphNodeTx(tx, c, node))
|
||||
@@ -788,7 +788,7 @@ func (c *KVStore) ForEachNode(cb func(tx NodeRTx) error) error {
|
||||
//
|
||||
// TODO(roasbeef): add iterator interface to allow for memory efficient graph
|
||||
// traversal when graph gets mega.
|
||||
func (c *KVStore) forEachNode(
|
||||
func forEachNode(db kvdb.Backend,
|
||||
cb func(kvdb.RTx, *models.LightningNode) error) error {
|
||||
|
||||
traversal := func(tx kvdb.RTx) error {
|
||||
@@ -819,7 +819,7 @@ func (c *KVStore) forEachNode(
|
||||
})
|
||||
}
|
||||
|
||||
return kvdb.View(c.db, traversal, func() {})
|
||||
return kvdb.View(db, traversal, func() {})
|
||||
}
|
||||
|
||||
// ForEachNodeCacheable iterates through all the stored vertices/nodes in the
|
||||
|
Reference in New Issue
Block a user