From 8660f76b20d1ecf4fdb7d86424171f7ec665bbf9 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Thu, 26 Jun 2025 10:48:11 +0200 Subject: [PATCH] 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. --- graph/db/kv_store.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index 87651e461..f6607623c 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -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