graphdb: pass context to PruneTip
This commit is contained in:
6 files changed
+16
-11
No files matched your search
+4
-2
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user