Skip to content

Commit 1d16c44

Browse files
committed
contractcourt: catch error when no historical bucket exists
For older nodes, this bucket was never created, so we'll get an error if we try and query it. In this commit, we catch this error like we do when a given channel doesn't have the information (but the bucket actually exists). Fixes lightningnetwork#6155
1 parent 0a91535 commit 1d16c44

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

channeldb/db.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ var dbTopLevelBuckets = [][]byte{
325325
metaBucket,
326326
closeSummaryBucket,
327327
outpointBucket,
328+
historicalChannelBucket,
328329
}
329330

330331
// Wipe completely deletes all saved state within all used buckets within the

channeldb/db_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -717,10 +717,11 @@ func TestFetchHistoricalChannel(t *testing.T) {
717717
// Create a an open channel in the database.
718718
channel := createTestChannel(t, cdb, openChannelOption())
719719

720-
// First, try to lookup a channel when the bucket does not
721-
// exist.
720+
// First, try to lookup a channel when nothing is in the bucket. As the
721+
// bucket is auto-created (on start up), we'll get a channel not found
722+
// error.
722723
_, err = cdb.FetchHistoricalChannel(&channel.FundingOutpoint)
723-
if err != ErrNoHistoricalBucket {
724+
if err != ErrChannelNotFound {
724725
t.Fatalf("expected no bucket, got: %v", err)
725726
}
726727

contractcourt/channel_arbitrator.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,8 @@ func (c *ChannelArbitrator) relaunchResolvers(commitSet *CommitSet,
618618
// If we don't find this channel, then it may be the case that it
619619
// was closed before we started to retain the final state
620620
// information for open channels.
621+
case err == channeldb.ErrNoHistoricalBucket:
622+
fallthrough
621623
case err == channeldb.ErrChannelNotFound:
622624
log.Warnf("ChannelArbitrator(%v): unable to fetch historical "+
623625
"state", c.cfg.ChanPoint)
@@ -1947,6 +1949,8 @@ func (c *ChannelArbitrator) prepContractResolutions(
19471949
// If we don't find this channel, then it may be the case that it
19481950
// was closed before we started to retain the final state
19491951
// information for open channels.
1952+
case err == channeldb.ErrNoHistoricalBucket:
1953+
fallthrough
19501954
case err == channeldb.ErrChannelNotFound:
19511955
log.Warnf("ChannelArbitrator(%v): unable to fetch historical "+
19521956
"state", c.cfg.ChanPoint)

0 commit comments

Comments
 (0)