multi: update FetchChanInfos to take in an optional tx

In this commit, the FetchChanInfos ChannelGraph method is updated to
take in an optional read transaction for the case where it is called
from within another transaction.
This commit is contained in:
Elle Mouton committed 2024-01-22 21:07:55 +02:00
1 parent 8cf4044215
commit 6c427a6ba9
4 files changed
+32 -14

No files matched your search

+9 -6
View File
@@ -1008,20 +1008,23 @@ func (r *ChannelRouter) pruneZombieChans() error {
if r.cfg.AssumeChannelValid {
disabledChanIDs, err := r.cfg.Graph.DisabledChannelIDs()
if err != nil {
return fmt.Errorf("unable to get disabled channels ids "+
"chans: %v", err)
return fmt.Errorf("unable to get disabled channels "+
"ids chans: %v", err)
}
disabledEdges, err := r.cfg.Graph.FetchChanInfos(disabledChanIDs)
disabledEdges, err := r.cfg.Graph.FetchChanInfos(
nil, disabledChanIDs,
)
if err != nil {
return fmt.Errorf("unable to fetch disabled channels edges "+
"chans: %v", err)
return fmt.Errorf("unable to fetch disabled channels "+
"edges chans: %v", err)
}
// Ensuring we won't prune our own channel from the graph.
for _, disabledEdge := range disabledEdges {
if !isSelfChannelEdge(disabledEdge.Info) {
chansToPrune[disabledEdge.Info.ChannelID] = struct{}{}
chansToPrune[disabledEdge.Info.ChannelID] =
struct{}{}
}
}
}