multi: use single read transaction for path finding

This commit partially reverts bf27d05a.
To avoid creating multiple database transactions during a single path
finding operation, we create an explicit transaction when the cached
graph is instantiated.
We cache the source node to avoid needing to look that up for every path
finding session.
The database transaction will be nil in case of the in-memory graph.
This commit is contained in:
Oliver Gugger committed 2021-10-22 09:32:49 +02:00
1 parent 1fef2970cf
commit 0a2ccfc52b
9 files changed
+105 -33

No files matched your search

+4 -3
View File
@@ -860,12 +860,13 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
MinProbability: routingConfig.MinRouteProbability,
}
cachedGraph, err := routing.NewCachedGraph(chanGraph)
sourceNode, err := chanGraph.SourceNode()
if err != nil {
return nil, err
return nil, fmt.Errorf("error getting source node: %v", err)
}
paymentSessionSource := &routing.SessionSource{
Graph: cachedGraph,
Graph: chanGraph,
SourceNode: sourceNode,
MissionControl: s.missionControl,
GetLink: s.htlcSwitch.GetLinkByShortID,
PathFindingConfig: pathFindingConfig,