graphdb: pass context to DisconnectBlockAtHeight
This commit is contained in:
6 files changed
+15
-15
No files matched your search
+4
-2
@@ -366,7 +366,9 @@ func (b *Builder) syncGraphWithChain() error {
|
||||
"(hash=%v)", pruneHeight, pruneHash)
|
||||
// Prune the graph for every channel that was opened at height
|
||||
// >= pruneHeight.
|
||||
_, err := b.cfg.Graph.DisconnectBlockAtHeight(pruneHeight)
|
||||
_, err := b.cfg.Graph.DisconnectBlockAtHeight(
|
||||
context.TODO(), pruneHeight,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -687,7 +689,7 @@ func (b *Builder) networkHandler() {
|
||||
// Update the channel graph to reflect that this block
|
||||
// was disconnected.
|
||||
_, err := b.cfg.Graph.DisconnectBlockAtHeight(
|
||||
blockHeight,
|
||||
context.TODO(), blockHeight,
|
||||
)
|
||||
if err != nil {
|
||||
log.Errorf("unable to prune graph with stale "+
|
||||
|
||||
+3
-3
@@ -419,10 +419,10 @@ func (c *ChannelGraph) DeleteChannelEdges(ctx context.Context,
|
||||
// set to the last prune height valid for the remaining chain.
|
||||
// Channels that were removed from the graph resulting from the
|
||||
// disconnected block are returned.
|
||||
func (c *ChannelGraph) DisconnectBlockAtHeight(height uint32) (
|
||||
[]*models.ChannelEdgeInfo, error) {
|
||||
func (c *ChannelGraph) DisconnectBlockAtHeight(ctx context.Context,
|
||||
height uint32) ([]*models.ChannelEdgeInfo, error) {
|
||||
|
||||
edges, err := c.db.DisconnectBlockAtHeight(height)
|
||||
edges, err := c.db.DisconnectBlockAtHeight(ctx, height)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -905,7 +905,7 @@ func TestDisconnectBlockAtHeight(t *testing.T) {
|
||||
|
||||
// Call DisconnectBlockAtHeight, which should prune every channel
|
||||
// that has a funding height of 'height' or greater.
|
||||
removed, err := graph.DisconnectBlockAtHeight(uint32(height))
|
||||
removed, err := graph.DisconnectBlockAtHeight(ctx, height)
|
||||
require.NoError(t, err)
|
||||
assertNoEdge(t, graph, edgeInfo.ChannelID)
|
||||
assertNoEdge(t, graph, edgeInfo2.ChannelID)
|
||||
@@ -3437,7 +3437,7 @@ func TestStressTestChannelGraphAPI(t *testing.T) {
|
||||
name: "DisconnectBlockAtHeight",
|
||||
fn: func() error {
|
||||
_, err := graph.DisconnectBlockAtHeight(
|
||||
newBlockHeight(),
|
||||
ctx, newBlockHeight(),
|
||||
)
|
||||
|
||||
return err
|
||||
|
||||
@@ -412,6 +412,6 @@ type Store interface { //nolint:interfacebloat
|
||||
// set to the last prune height valid for the remaining chain.
|
||||
// Channels that were removed from the graph resulting from the
|
||||
// disconnected block are returned.
|
||||
DisconnectBlockAtHeight(height uint32) ([]*models.ChannelEdgeInfo,
|
||||
error)
|
||||
DisconnectBlockAtHeight(ctx context.Context,
|
||||
height uint32) ([]*models.ChannelEdgeInfo, error)
|
||||
}
|
||||
@@ -1760,8 +1760,8 @@ func (c *KVStore) pruneGraphNodes(nodes kvdb.RwBucket,
|
||||
// set to the last prune height valid for the remaining chain.
|
||||
// Channels that were removed from the graph resulting from the
|
||||
// disconnected block are returned.
|
||||
func (c *KVStore) DisconnectBlockAtHeight(height uint32) (
|
||||
[]*models.ChannelEdgeInfo, error) {
|
||||
func (c *KVStore) DisconnectBlockAtHeight(_ context.Context,
|
||||
height uint32) ([]*models.ChannelEdgeInfo, error) {
|
||||
|
||||
// Every channel having a ShortChannelID starting at 'height'
|
||||
// will no longer be confirmed.
|
||||
|
||||
@@ -3112,10 +3112,8 @@ func (s *SQLStore) pruneGraphNodes(ctx context.Context,
|
||||
// disconnected block are returned.
|
||||
//
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) DisconnectBlockAtHeight(height uint32) (
|
||||
[]*models.ChannelEdgeInfo, error) {
|
||||
|
||||
ctx := context.TODO()
|
||||
func (s *SQLStore) DisconnectBlockAtHeight(ctx context.Context,
|
||||
height uint32) ([]*models.ChannelEdgeInfo, error) {
|
||||
|
||||
var (
|
||||
// Every channel having a ShortChannelID starting at 'height'
|
||||
|
||||
Reference in new issue
Block a user