Skip to content

Commit 8660f76

Browse files
committed
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.
1 parent cd7fa63 commit 8660f76

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

graph/db/kv_store.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ func (c *KVStore) ForEachNodeCached(cb func(node route.Vertex,
658658
// We'll iterate over each node, then the set of channels for each
659659
// node, and construct a similar callback functiopn signature as the
660660
// main funcotin expects.
661-
return c.forEachNode(func(tx kvdb.RTx,
661+
return forEachNode(c.db, func(tx kvdb.RTx,
662662
node *models.LightningNode) error {
663663

664664
channels := make(map[uint64]*DirectedChannel)
@@ -774,7 +774,7 @@ func (c *KVStore) DisabledChannelIDs() ([]uint64, error) {
774774
// executed under the same read transaction and so, methods on the NodeTx object
775775
// _MUST_ only be called from within the call-back.
776776
func (c *KVStore) ForEachNode(cb func(tx NodeRTx) error) error {
777-
return c.forEachNode(func(tx kvdb.RTx,
777+
return forEachNode(c.db, func(tx kvdb.RTx,
778778
node *models.LightningNode) error {
779779

780780
return cb(newChanGraphNodeTx(tx, c, node))
@@ -788,7 +788,7 @@ func (c *KVStore) ForEachNode(cb func(tx NodeRTx) error) error {
788788
//
789789
// TODO(roasbeef): add iterator interface to allow for memory efficient graph
790790
// traversal when graph gets mega.
791-
func (c *KVStore) forEachNode(
791+
func forEachNode(db kvdb.Backend,
792792
cb func(kvdb.RTx, *models.LightningNode) error) error {
793793

794794
traversal := func(tx kvdb.RTx) error {
@@ -819,7 +819,7 @@ func (c *KVStore) forEachNode(
819819
})
820820
}
821821

822-
return kvdb.View(c.db, traversal, func() {})
822+
return kvdb.View(db, traversal, func() {})
823823
}
824824

825825
// ForEachNodeCacheable iterates through all the stored vertices/nodes in the

0 commit comments

Comments
 (0)