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