multi: pass reset to GraphSession

This commit is contained in:
Elle Mouton committed 2025-07-15 11:25:09 +02:00
1 parent e17fd58a1d
commit b3f3766fe6
9 files changed
+23 -14

No files matched your search

+4 -2
View File
@@ -233,12 +233,14 @@ func (c *ChannelGraph) FetchNodeFeatures(node route.Vertex) (
// instance which can be used to perform queries against the channel graph. If
// the graph cache is not enabled, then the call-back will be provided with
// access to the graph via a consistent read-only transaction.
func (c *ChannelGraph) GraphSession(cb func(graph NodeTraverser) error) error {
func (c *ChannelGraph) GraphSession(cb func(graph NodeTraverser) error,
reset func()) error {
if c.graphCache != nil {
return cb(c)
}
return c.V1Store.GraphSession(cb)
return c.V1Store.GraphSession(cb, reset)
}
// ForEachNodeCached iterates through all the stored vertices/nodes in the
+1 -1
View File
@@ -149,7 +149,7 @@ type V1Store interface { //nolint:interfacebloat
// GraphSession will provide the call-back with access to a
// NodeTraverser instance which can be used to perform queries against
// the channel graph.
GraphSession(cb func(graph NodeTraverser) error) error
GraphSession(cb func(graph NodeTraverser) error, reset func()) error
// ForEachChannel iterates through all the channel edges stored within
// the graph and invokes the passed callback for each edge. The callback
+2 -2
View File
@@ -3977,8 +3977,8 @@ func (c *KVStore) IsClosedScid(scid lnwire.ShortChannelID) (bool, error) {
// GraphSession will provide the call-back with access to a NodeTraverser
// instance which can be used to perform queries against the channel graph.
func (c *KVStore) GraphSession(cb func(graph NodeTraverser) error) error {
reset := func() {}
func (c *KVStore) GraphSession(cb func(graph NodeTraverser) error,
reset func()) error {
return c.db.View(func(tx walletdb.ReadTx) error {
return cb(&nodeTraverserSession{
+3 -3
View File
@@ -2757,10 +2757,10 @@ func (s *SQLStore) IsClosedScid(scid lnwire.ShortChannelID) (bool, error) {
// instance which can be used to perform queries against the channel graph.
//
// NOTE: part of the V1Store interface.
func (s *SQLStore) GraphSession(cb func(graph NodeTraverser) error) error {
var ctx = context.TODO()
func (s *SQLStore) GraphSession(cb func(graph NodeTraverser) error,
reset func()) error {
reset := func() {}
var ctx = context.TODO()
return s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
return cb(newSQLNodeTraverser(db, s.cfg.ChainHash))
+2 -1
View File
@@ -29,7 +29,8 @@ type GraphSessionFactory interface {
// GraphSession will provide the call-back with access to a
// graphdb.NodeTraverser instance which can be used to perform queries
// against the channel graph.
GraphSession(cb func(graph graphdb.NodeTraverser) error) error
GraphSession(cb func(graph graphdb.NodeTraverser) error,
reset func()) error
}
// FetchAmountPairCapacity determines the maximal public capacity between two
+2 -2
View File
@@ -232,8 +232,8 @@ func (m *mockGraph) FetchNodeFeatures(nodePub route.Vertex) (
// the channel graph.
//
// NOTE: Part of the GraphSessionFactory interface.
func (m *mockGraph) GraphSession(
cb func(graph graphdb.NodeTraverser) error) error {
func (m *mockGraph) GraphSession(cb func(graph graphdb.NodeTraverser) error,
_ func()) error {
return cb(m)
}
+2
View File
@@ -3303,6 +3303,8 @@ func dbFindPath(graph *graphdb.ChannelGraph,
)
return err
}, func() {
route = nil
})
if err != nil {
return nil, err
+5 -1
View File
@@ -343,7 +343,11 @@ func (p *paymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi,
}
for {
err := p.graphSessFactory.GraphSession(findPath)
err := p.graphSessFactory.GraphSession(
findPath, func() {
path = nil
},
)
// If there is an error, and it is not a path finding error, we
// return it immediately.
if err != nil && !lnutils.ErrorAs[*pathFindingError](err) {
+2 -2
View File
@@ -259,8 +259,8 @@ func (g *sessionGraph) sourceNode() route.Vertex {
return route.Vertex{}
}
func (g *sessionGraph) GraphSession(
cb func(graph graphdb.NodeTraverser) error) error {
func (g *sessionGraph) GraphSession(cb func(graph graphdb.NodeTraverser) error,
_ func()) error {
return cb(g)
}