diff --git a/graph/builder.go b/graph/builder.go index ba3c508fd..a471e9525 100644 --- a/graph/builder.go +++ b/graph/builder.go @@ -175,7 +175,7 @@ func (b *Builder) Start() error { // If the graph has never been pruned, or hasn't fully been created yet, // then we don't treat this as an explicit error. - if _, _, err := b.cfg.Graph.PruneTip(); err != nil { + if _, _, err := b.cfg.Graph.PruneTip(context.TODO()); err != nil { switch { case errors.Is(err, graphdb.ErrGraphNeverPruned): fallthrough @@ -324,7 +324,7 @@ func (b *Builder) syncGraphWithChain() error { } b.bestHeight.Store(uint32(bestHeight)) - pruneHash, pruneHeight, err := b.cfg.Graph.PruneTip() + pruneHash, pruneHeight, err := b.cfg.Graph.PruneTip(context.TODO()) if err != nil { switch { // If the graph has never been pruned, or hasn't fully been @@ -371,7 +371,9 @@ func (b *Builder) syncGraphWithChain() error { return err } - pruneHash, pruneHeight, err = b.cfg.Graph.PruneTip() + pruneHash, pruneHeight, err = b.cfg.Graph.PruneTip( + context.TODO(), + ) switch { // If at this point the graph has never been pruned, we can exit // as this entails we are back to the point where it hasn't seen diff --git a/graph/db/graph.go b/graph/db/graph.go index 38924c89f..fd32348e9 100644 --- a/graph/db/graph.go +++ b/graph/db/graph.go @@ -789,8 +789,10 @@ func (c *ChannelGraph) SetSourceNode(ctx context.Context, } // PruneTip returns the block height and hash of the latest pruning block. -func (c *ChannelGraph) PruneTip() (*chainhash.Hash, uint32, error) { - return c.db.PruneTip() +func (c *ChannelGraph) PruneTip(ctx context.Context) (*chainhash.Hash, + uint32, error) { + + return c.db.PruneTip(ctx) } // VersionedGraph is a wrapper around ChannelGraph that will call underlying diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index 7e69e49cd..4ad0ae336 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -940,7 +940,7 @@ func TestDisconnectBlockAtHeight(t *testing.T) { // PruneTip should be set to the blockHash we specified for the block // at height 155. - hash, h, err := graph.PruneTip() + hash, h, err := graph.PruneTip(ctx) require.NoError(t, err, "unable to get prune tip") require.True(t, blockHash.IsEqual(hash)) require.Equal(t, h, height-1) @@ -2122,7 +2122,7 @@ func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes, func assertPruneTip(t *testing.T, graph *ChannelGraph, blockHash *chainhash.Hash, blockHeight uint32) { - pruneHash, pruneHeight, err := graph.PruneTip() + pruneHash, pruneHeight, err := graph.PruneTip(t.Context()) require.NoError(t, err) require.Equal(t, blockHash[:], pruneHash[:]) require.Equal(t, blockHeight, pruneHeight) diff --git a/graph/db/interfaces.go b/graph/db/interfaces.go index dec3dba98..27dcb042c 100644 --- a/graph/db/interfaces.go +++ b/graph/db/interfaces.go @@ -383,7 +383,7 @@ type Store interface { //nolint:interfacebloat // has been used to prune channels in the graph. Knowing the "prune tip" // allows callers to tell if the graph is currently in sync with the // current best known UTXO state. - PruneTip() (*chainhash.Hash, uint32, error) + PruneTip(ctx context.Context) (*chainhash.Hash, uint32, error) // PruneGraphNodes is a garbage collection method which attempts to // prune out any nodes from the channel graph that are currently diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index b6e40d8a4..a5a324d28 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -1887,7 +1887,7 @@ func (c *KVStore) DisconnectBlockAtHeight(height uint32) ( // used to prune channels in the graph. Knowing the "prune tip" allows callers // to tell if the graph is currently in sync with the current best known UTXO // state. -func (c *KVStore) PruneTip() (*chainhash.Hash, uint32, error) { +func (c *KVStore) PruneTip(_ context.Context) (*chainhash.Hash, uint32, error) { var ( tipHash chainhash.Hash tipHeight uint32 diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index 70fd26cd2..406b16d39 100644 --- a/graph/db/sql_store.go +++ b/graph/db/sql_store.go @@ -3049,9 +3049,10 @@ func (s *SQLStore) ChannelView(ctx context.Context) ([]EdgePoint, error) { // state. // // NOTE: part of the Store interface. -func (s *SQLStore) PruneTip() (*chainhash.Hash, uint32, error) { +func (s *SQLStore) PruneTip(ctx context.Context) (*chainhash.Hash, uint32, + error) { + var ( - ctx = context.TODO() tipHash chainhash.Hash tipHeight uint32 )