@@ -503,9 +503,12 @@ func (c *ChannelGraph) ForEachChannel(cb func(*models.ChannelEdgeInfo,
503
503
// ForEachNodeDirectedChannel iterates through all channels of a given node,
504
504
// executing the passed callback on the directed edge representing the channel
505
505
// and its incoming policy. If the callback returns an error, then the iteration
506
- // is halted with the error propagated back up to the caller.
506
+ // is halted with the error propagated back up to the caller. An optional read
507
+ // transaction may be provided. If none is provided, a new one will be created.
507
508
//
508
509
// Unknown policies are passed into the callback as nil values.
510
+ //
511
+ // NOTE: this is part of the graphsession.graph interface.
509
512
func (c * ChannelGraph ) ForEachNodeDirectedChannel (tx kvdb.RTx ,
510
513
node route.Vertex , cb func (channel * DirectedChannel ) error ) error {
511
514
@@ -517,7 +520,7 @@ func (c *ChannelGraph) ForEachNodeDirectedChannel(tx kvdb.RTx,
517
520
toNodeCallback := func () route.Vertex {
518
521
return node
519
522
}
520
- toNodeFeatures , err := c .FetchNodeFeatures (node )
523
+ toNodeFeatures , err := c .FetchNodeFeatures (tx , node )
521
524
if err != nil {
522
525
return err
523
526
}
@@ -562,16 +565,19 @@ func (c *ChannelGraph) ForEachNodeDirectedChannel(tx kvdb.RTx,
562
565
}
563
566
564
567
// FetchNodeFeatures returns the features of a given node. If no features are
565
- // known for the node, an empty feature vector is returned.
566
- func (c * ChannelGraph ) FetchNodeFeatures (
568
+ // known for the node, an empty feature vector is returned. An optional read
569
+ // transaction may be provided. If none is provided, a new one will be created.
570
+ //
571
+ // NOTE: this is part of the graphsession.graph interface.
572
+ func (c * ChannelGraph ) FetchNodeFeatures (tx kvdb.RTx ,
567
573
node route.Vertex ) (* lnwire.FeatureVector , error ) {
568
574
569
575
if c .graphCache != nil {
570
576
return c .graphCache .GetFeatures (node ), nil
571
577
}
572
578
573
579
// Fallback that uses the database.
574
- targetNode , err := c .FetchLightningNode ( node )
580
+ targetNode , err := c .FetchLightningNodeTx ( tx , node )
575
581
switch err {
576
582
// If the node exists and has features, return them directly.
577
583
case nil :
@@ -618,7 +624,7 @@ func (c *ChannelGraph) ForEachNodeCached(cb func(node route.Vertex,
618
624
return node .PubKeyBytes
619
625
}
620
626
toNodeFeatures , err := c .FetchNodeFeatures (
621
- node .PubKeyBytes ,
627
+ tx , node .PubKeyBytes ,
622
628
)
623
629
if err != nil {
624
630
return err
0 commit comments