graphdb: pass context to PruneGraphNodes
This commit is contained in:
6 files changed
+9
-9
No files matched your search
+2
-2
@@ -268,7 +268,7 @@ func (b *Builder) Start() error {
|
||||
// Finally, before we proceed, we'll prune any unconnected nodes
|
||||
// from the graph in order to ensure we maintain a tight graph
|
||||
// of "useful" nodes.
|
||||
err = b.cfg.Graph.PruneGraphNodes()
|
||||
err = b.cfg.Graph.PruneGraphNodes(context.TODO())
|
||||
if err != nil &&
|
||||
!errors.Is(err, graphdb.ErrGraphNodesNotFound) {
|
||||
|
||||
@@ -638,7 +638,7 @@ func (b *Builder) pruneZombieChans() error {
|
||||
|
||||
// With the channels pruned, we'll also attempt to prune any nodes that
|
||||
// were a part of them.
|
||||
err = b.cfg.Graph.PruneGraphNodes()
|
||||
err = b.cfg.Graph.PruneGraphNodes(context.TODO())
|
||||
if err != nil && !errors.Is(err, graphdb.ErrGraphNodesNotFound) {
|
||||
return fmt.Errorf("unable to prune graph nodes: %w", err)
|
||||
}
|
||||
|
||||
+2
-2
@@ -494,8 +494,8 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint,
|
||||
// any nodes from the channel graph that are currently unconnected. This ensure
|
||||
// that we only maintain a graph of reachable nodes. In the event that a pruned
|
||||
// node gains more channels, it will be re-added back to the graph.
|
||||
func (c *ChannelGraph) PruneGraphNodes() error {
|
||||
nodes, err := c.db.PruneGraphNodes()
|
||||
func (c *ChannelGraph) PruneGraphNodes(ctx context.Context) error {
|
||||
nodes, err := c.db.PruneGraphNodes(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -4044,7 +4044,7 @@ func TestPruneGraphNodes(t *testing.T) {
|
||||
require.NoError(t, graph.UpdateEdgePolicy(ctx, edge1))
|
||||
|
||||
// We'll now initiate a around of graph pruning.
|
||||
require.NoError(t, graph.PruneGraphNodes())
|
||||
require.NoError(t, graph.PruneGraphNodes(ctx))
|
||||
|
||||
// At this point, there should be 3 nodes left in the graph still: the
|
||||
// source node (which can't be pruned), and node 1+2. Nodes 1 and two
|
||||
|
||||
@@ -390,7 +390,7 @@ type Store interface { //nolint:interfacebloat
|
||||
// unconnected. This ensures that we only maintain a graph of reachable
|
||||
// nodes. In the event that a pruned node gains more channels, it will
|
||||
// be re-added back to the graph.
|
||||
PruneGraphNodes() ([]route.Vertex, error)
|
||||
PruneGraphNodes(ctx context.Context) ([]route.Vertex, error)
|
||||
|
||||
// PruneGraph prunes newly closed channels from the channel graph in
|
||||
// response to a new block being solved on the network. Any transactions
|
||||
|
||||
@@ -1620,7 +1620,7 @@ func (c *KVStore) PruneGraph(spentOutputs []*wire.OutPoint,
|
||||
// any nodes from the channel graph that are currently unconnected. This ensure
|
||||
// that we only maintain a graph of reachable nodes. In the event that a pruned
|
||||
// node gains more channels, it will be re-added back to the graph.
|
||||
func (c *KVStore) PruneGraphNodes() ([]route.Vertex, error) {
|
||||
func (c *KVStore) PruneGraphNodes(_ context.Context) ([]route.Vertex, error) {
|
||||
var prunedNodes []route.Vertex
|
||||
err := kvdb.Update(c.db, func(tx kvdb.RwTx) error {
|
||||
nodes := tx.ReadWriteBucket(nodeBucket)
|
||||
|
||||
@@ -2802,8 +2802,8 @@ func (s *SQLStore) forEachChanInSCIDList(ctx context.Context, db SQLQueries,
|
||||
// source nodes.
|
||||
//
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) PruneGraphNodes() ([]route.Vertex, error) {
|
||||
var ctx = context.TODO()
|
||||
func (s *SQLStore) PruneGraphNodes(ctx context.Context) (
|
||||
[]route.Vertex, error) {
|
||||
|
||||
var prunedNodes []route.Vertex
|
||||
err := s.db.ExecTx(ctx, sqldb.WriteTxOpt(), func(db SQLQueries) error {
|
||||
|
||||
Reference in new issue
Block a user