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
2021-10-21 13:55:22 +02:00
parent 1fef2970cf
commit 0a2ccfc52b
9 changed files with 105 additions and 33 deletions

View File

@ -116,10 +116,12 @@ func TestUpdateAdditionalEdge(t *testing.T) {
// Create the paymentsession.
session, err := newPaymentSession(
payment,
func() (bandwidthHints, error) {
func(routingGraph) (bandwidthHints, error) {
return &mockBandwidthHints{}, nil
},
&sessionGraph{},
func() (routingGraph, func(), error) {
return &sessionGraph{}, func() {}, nil
},
&MissionControl{},
PathFindingConfig{},
)
@ -194,10 +196,12 @@ func TestRequestRoute(t *testing.T) {
session, err := newPaymentSession(
payment,
func() (bandwidthHints, error) {
func(routingGraph) (bandwidthHints, error) {
return &mockBandwidthHints{}, nil
},
&sessionGraph{},
func() (routingGraph, func(), error) {
return &sessionGraph{}, func() {}, nil
},
&MissionControl{},
PathFindingConfig{},
)