graph/db+server: let ForEachSourceNodeChannel take a context
This commit is contained in:
5 files changed
+13
-12
No files matched your search
@@ -1311,7 +1311,7 @@ func TestForEachSourceNodeChannel(t *testing.T) {
|
||||
|
||||
// Now, we'll use the ForEachSourceNodeChannel and assert that it
|
||||
// returns the expected data in the call-back.
|
||||
err := graph.ForEachSourceNodeChannel(func(chanPoint wire.OutPoint,
|
||||
err := graph.ForEachSourceNodeChannel(ctx, func(chanPoint wire.OutPoint,
|
||||
havePolicy bool, otherNode *models.LightningNode) error {
|
||||
|
||||
require.Contains(t, expectedSrcChans, chanPoint)
|
||||
|
||||
@@ -70,8 +70,9 @@ type V1Store interface { //nolint:interfacebloat
|
||||
// node, executing the passed callback on each. The call-back is
|
||||
// provided with the channel's outpoint, whether we have a policy for
|
||||
// the channel and the channel peer's node information.
|
||||
ForEachSourceNodeChannel(cb func(chanPoint wire.OutPoint,
|
||||
havePolicy bool, otherNode *models.LightningNode) error) error
|
||||
ForEachSourceNodeChannel(ctx context.Context,
|
||||
cb func(chanPoint wire.OutPoint, havePolicy bool,
|
||||
otherNode *models.LightningNode) error) error
|
||||
|
||||
// ForEachNodeChannel iterates through all channels of the given node,
|
||||
// executing the passed callback with an edge info structure and the
|
||||
|
||||
@@ -3248,8 +3248,9 @@ func (c *KVStore) ForEachNodeChannel(nodePub route.Vertex,
|
||||
// executing the passed callback on each. The callback is provided with the
|
||||
// channel's outpoint, whether we have a policy for the channel and the channel
|
||||
// peer's node information.
|
||||
func (c *KVStore) ForEachSourceNodeChannel(cb func(chanPoint wire.OutPoint,
|
||||
havePolicy bool, otherNode *models.LightningNode) error) error {
|
||||
func (c *KVStore) ForEachSourceNodeChannel(_ context.Context,
|
||||
cb func(chanPoint wire.OutPoint, havePolicy bool,
|
||||
otherNode *models.LightningNode) error) error {
|
||||
|
||||
return kvdb.View(c.db, func(tx kvdb.RTx) error {
|
||||
nodes := tx.ReadBucket(nodeBucket)
|
||||
|
||||
@@ -724,10 +724,9 @@ func (s *SQLStore) updateEdgeCache(e *models.ChannelEdgePolicy,
|
||||
// peer's node information.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
func (s *SQLStore) ForEachSourceNodeChannel(cb func(chanPoint wire.OutPoint,
|
||||
havePolicy bool, otherNode *models.LightningNode) error) error {
|
||||
|
||||
var ctx = context.TODO()
|
||||
func (s *SQLStore) ForEachSourceNodeChannel(ctx context.Context,
|
||||
cb func(chanPoint wire.OutPoint, havePolicy bool,
|
||||
otherNode *models.LightningNode) error) error {
|
||||
|
||||
return s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
||||
nodeID, nodePub, err := s.getSourceNode(ctx, db, ProtocolV1)
|
||||
|
||||
Reference in new issue
Block a user