funding: use FundingBrodcastHeight as height hint for conf registrations
This commit is contained in:
parent
66ba2e862c
commit
e72b030054
@ -145,11 +145,6 @@ type fundingConfig struct {
|
|||||||
// so that the channel creation process can be completed.
|
// so that the channel creation process can be completed.
|
||||||
Notifier chainntnfs.ChainNotifier
|
Notifier chainntnfs.ChainNotifier
|
||||||
|
|
||||||
// ChainIO is used by the FundingManager to determine the current
|
|
||||||
// height so it's able to reduce the search space for certain
|
|
||||||
// ChainNotifier implementations when registering for confirmations.
|
|
||||||
ChainIO lnwallet.BlockChainIO
|
|
||||||
|
|
||||||
// SignMessage signs an arbitrary method with a given public key. The
|
// SignMessage signs an arbitrary method with a given public key. The
|
||||||
// actual digest signed is the double sha-256 of the message. In the
|
// actual digest signed is the double sha-256 of the message. In the
|
||||||
// case that the private key corresponding to the passed public key
|
// case that the private key corresponding to the passed public key
|
||||||
@ -269,11 +264,6 @@ func (f *fundingManager) Start() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, currentHeight, err := f.cfg.ChainIO.GetBestBlock()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// For any channels that were in a pending state when the daemon was
|
// For any channels that were in a pending state when the daemon was
|
||||||
// last connected, the Funding Manager will re-initialize the channel
|
// last connected, the Funding Manager will re-initialize the channel
|
||||||
// barriers and will also launch waitForFundingConfirmation to wait for
|
// barriers and will also launch waitForFundingConfirmation to wait for
|
||||||
@ -287,7 +277,7 @@ func (f *fundingManager) Start() error {
|
|||||||
f.barrierMtx.Unlock()
|
f.barrierMtx.Unlock()
|
||||||
|
|
||||||
doneChan := make(chan struct{})
|
doneChan := make(chan struct{})
|
||||||
go f.waitForFundingConfirmation(channel, uint32(currentHeight), doneChan)
|
go f.waitForFundingConfirmation(channel, doneChan)
|
||||||
}
|
}
|
||||||
|
|
||||||
f.wg.Add(1) // TODO(roasbeef): tune
|
f.wg.Add(1) // TODO(roasbeef): tune
|
||||||
@ -807,15 +797,9 @@ func (f *fundingManager) handleFundingComplete(fmsg *fundingCompleteMsg) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, bestHeight, err := f.cfg.ChainIO.GetBestBlock()
|
|
||||||
if err != nil {
|
|
||||||
fndgLog.Errorf("unable to get best height: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
doneChan := make(chan struct{})
|
doneChan := make(chan struct{})
|
||||||
go f.waitForFundingConfirmation(completeChan,
|
go f.waitForFundingConfirmation(completeChan, doneChan)
|
||||||
uint32(bestHeight), doneChan)
|
|
||||||
|
|
||||||
<-doneChan
|
<-doneChan
|
||||||
f.deleteReservationCtx(peerKey, fmsg.msg.PendingChannelID)
|
f.deleteReservationCtx(peerKey, fmsg.msg.PendingChannelID)
|
||||||
@ -877,15 +861,9 @@ func (f *fundingManager) handleFundingSignComplete(fmsg *fundingSignCompleteMsg)
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
_, bestHeight, err := f.cfg.ChainIO.GetBestBlock()
|
|
||||||
if err != nil {
|
|
||||||
fndgLog.Errorf("unable to get best height: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
doneChan := make(chan struct{})
|
doneChan := make(chan struct{})
|
||||||
go f.waitForFundingConfirmation(completeChan, uint32(bestHeight),
|
go f.waitForFundingConfirmation(completeChan, doneChan)
|
||||||
doneChan)
|
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-f.quit:
|
case <-f.quit:
|
||||||
@ -917,7 +895,7 @@ func (f *fundingManager) handleFundingSignComplete(fmsg *fundingSignCompleteMsg)
|
|||||||
// confirmation, and then to notify the other systems that must be notified
|
// confirmation, and then to notify the other systems that must be notified
|
||||||
// when a channel has become active for lightning transactions.
|
// when a channel has become active for lightning transactions.
|
||||||
func (f *fundingManager) waitForFundingConfirmation(completeChan *channeldb.OpenChannel,
|
func (f *fundingManager) waitForFundingConfirmation(completeChan *channeldb.OpenChannel,
|
||||||
bestHeight uint32, doneChan chan struct{}) {
|
doneChan chan struct{}) {
|
||||||
|
|
||||||
defer close(doneChan)
|
defer close(doneChan)
|
||||||
|
|
||||||
@ -926,7 +904,7 @@ func (f *fundingManager) waitForFundingConfirmation(completeChan *channeldb.Open
|
|||||||
txid := completeChan.FundingOutpoint.Hash
|
txid := completeChan.FundingOutpoint.Hash
|
||||||
numConfs := uint32(completeChan.NumConfsRequired)
|
numConfs := uint32(completeChan.NumConfsRequired)
|
||||||
confNtfn, err := f.cfg.Notifier.RegisterConfirmationsNtfn(&txid,
|
confNtfn, err := f.cfg.Notifier.RegisterConfirmationsNtfn(&txid,
|
||||||
numConfs, bestHeight)
|
numConfs, completeChan.FundingBroadcastHeight)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fndgLog.Errorf("Unable to register for confirmation of "+
|
fndgLog.Errorf("Unable to register for confirmation of "+
|
||||||
"ChannelPoint(%v)", completeChan.FundingOutpoint)
|
"ChannelPoint(%v)", completeChan.FundingOutpoint)
|
||||||
|
Loading…
Reference in New Issue
Block a user