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