channeldb: BigSize migration, store zero-conf, scid-alias bits

This introduces a BigSize migration that is used to expand the width
of the ChannelStatus and ChannelType fields. Three channel "types"
are added - ZeroConfBit, ScidAliasChanBit, and ScidAliasFeatureBit.
ScidAliasChanBit denotes that the scid-alias channel type was
negotiated for the channel. ScidAliasFeatureBit denotes that the
scid-alias feature bit was negotiated during the *lifetime* of the
channel. Several helper functions on the OpenChannel struct are
exposed to aid callers from different packages.

The RefreshShortChanID has been renamed to Refresh.

A new function BroadcastHeight is used to guard access to the
mutable FundingBroadcastHeight member. This prevents data races.
This commit is contained in:
eugene
2022-04-04 16:09:15 -04:00
parent 3ff8eb899c
commit c9f5912601
13 changed files with 503 additions and 28 deletions

View File

@@ -2306,7 +2306,7 @@ func (f *Manager) waitForFundingConfirmation(
numConfs := uint32(completeChan.NumConfsRequired)
confNtfn, err := f.cfg.Notifier.RegisterConfirmationsNtfn(
&txid, fundingScript, numConfs,
completeChan.FundingBroadcastHeight,
completeChan.BroadcastHeight(),
)
if err != nil {
log.Errorf("Unable to register for confirmation of "+
@@ -2392,7 +2392,8 @@ func (f *Manager) waitForTimeout(completeChan *channeldb.OpenChannel,
defer epochClient.Cancel()
// On block maxHeight we will cancel the funding confirmation wait.
maxHeight := completeChan.FundingBroadcastHeight + maxWaitNumBlocksFundingConf
broadcastHeight := completeChan.BroadcastHeight()
maxHeight := broadcastHeight + maxWaitNumBlocksFundingConf
for {
select {
case epoch, ok := <-epochClient.Epochs:
@@ -2738,7 +2739,7 @@ func (f *Manager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
// funding transaction reaches at least 6 confirmations.
confNtfn, err := f.cfg.Notifier.RegisterConfirmationsNtfn(
&txid, fundingScript, numConfs,
completeChan.FundingBroadcastHeight,
completeChan.BroadcastHeight(),
)
if err != nil {
return fmt.Errorf("unable to register for "+