multi: convert the existing channeldb.ChannelType uint8 into a bit field
In this commit, we convert the existing `channeldb.ChannelType` type into a _bit field_. This doesn't require us to change the current serialization or interpretation or the type as it is, since all the current defined values us a distinct bit. This PR lays the ground work for any future changes that may introduce new channel types (like anchor outputs), and also any changes that may modify the existing invariants around channels (if we're the initiator, we always have the funding transaction).
This commit is contained in:
14 files changed
+42
-39
No files matched your search
@@ -511,7 +511,7 @@ func testDualFundingReservationWorkflow(miner *rpctest.Harness,
|
||||
if !bytes.Equal(aliceChannels[0].FundingOutpoint.Hash[:], fundingSha[:]) {
|
||||
t.Fatalf("channel state not properly saved")
|
||||
}
|
||||
if aliceChannels[0].ChanType != channeldb.DualFunder {
|
||||
if !aliceChannels[0].ChanType.IsDualFunder() {
|
||||
t.Fatalf("channel not detected as dual funder")
|
||||
}
|
||||
bobChannels, err := bob.Cfg.Database.FetchOpenChannels(alicePub)
|
||||
@@ -521,7 +521,7 @@ func testDualFundingReservationWorkflow(miner *rpctest.Harness,
|
||||
if !bytes.Equal(bobChannels[0].FundingOutpoint.Hash[:], fundingSha[:]) {
|
||||
t.Fatalf("channel state not properly saved")
|
||||
}
|
||||
if bobChannels[0].ChanType != channeldb.DualFunder {
|
||||
if !bobChannels[0].ChanType.IsDualFunder() {
|
||||
t.Fatalf("channel not detected as dual funder")
|
||||
}
|
||||
|
||||
@@ -971,7 +971,7 @@ func testSingleFunderReservationWorkflow(miner *rpctest.Harness,
|
||||
}
|
||||
if !aliceChannels[0].ChanType.IsSingleFunder() {
|
||||
t.Fatalf("channel type is incorrect, expected %v instead got %v",
|
||||
channeldb.SingleFunder, aliceChannels[0].ChanType)
|
||||
channeldb.SingleFunderBit, aliceChannels[0].ChanType)
|
||||
}
|
||||
|
||||
bobChannels, err := bob.Cfg.Database.FetchOpenChannels(alicePub)
|
||||
@@ -991,7 +991,7 @@ func testSingleFunderReservationWorkflow(miner *rpctest.Harness,
|
||||
}
|
||||
if !bobChannels[0].ChanType.IsSingleFunder() {
|
||||
t.Fatalf("channel type is incorrect, expected %v instead got %v",
|
||||
channeldb.SingleFunder, bobChannels[0].ChanType)
|
||||
channeldb.SingleFunderBit, bobChannels[0].ChanType)
|
||||
}
|
||||
|
||||
// Let Alice publish the funding transaction.
|
||||
|
||||
Reference in new issue
Block a user