funding: use FundingBrodcastHeight as height hint for conf registrations

This commit is contained in:
Olaoluwa Osuntokun 2017-06-05 15:04:26 -07:00
parent 66ba2e862c
commit e72b030054
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

View File

@ -145,11 +145,6 @@ type fundingConfig struct {
// so that the channel creation process can be completed.
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
// actual digest signed is the double sha-256 of the message. In the
// case that the private key corresponding to the passed public key
@ -269,11 +264,6 @@ func (f *fundingManager) Start() error {
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
// last connected, the Funding Manager will re-initialize the channel
// barriers and will also launch waitForFundingConfirmation to wait for
@ -287,7 +277,7 @@ func (f *fundingManager) Start() error {
f.barrierMtx.Unlock()
doneChan := make(chan struct{})
go f.waitForFundingConfirmation(channel, uint32(currentHeight), doneChan)
go f.waitForFundingConfirmation(channel, doneChan)
}
f.wg.Add(1) // TODO(roasbeef): tune
@ -807,15 +797,9 @@ func (f *fundingManager) handleFundingComplete(fmsg *fundingCompleteMsg) {
return
}
_, bestHeight, err := f.cfg.ChainIO.GetBestBlock()
if err != nil {
fndgLog.Errorf("unable to get best height: %v", err)
}
go func() {
doneChan := make(chan struct{})
go f.waitForFundingConfirmation(completeChan,
uint32(bestHeight), doneChan)
go f.waitForFundingConfirmation(completeChan, doneChan)
<-doneChan
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() {
doneChan := make(chan struct{})
go f.waitForFundingConfirmation(completeChan, uint32(bestHeight),
doneChan)
go f.waitForFundingConfirmation(completeChan, doneChan)
select {
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
// when a channel has become active for lightning transactions.
func (f *fundingManager) waitForFundingConfirmation(completeChan *channeldb.OpenChannel,
bestHeight uint32, doneChan chan struct{}) {
doneChan chan struct{}) {
defer close(doneChan)
@ -926,7 +904,7 @@ func (f *fundingManager) waitForFundingConfirmation(completeChan *channeldb.Open
txid := completeChan.FundingOutpoint.Hash
numConfs := uint32(completeChan.NumConfsRequired)
confNtfn, err := f.cfg.Notifier.RegisterConfirmationsNtfn(&txid,
numConfs, bestHeight)
numConfs, completeChan.FundingBroadcastHeight)
if err != nil {
fndgLog.Errorf("Unable to register for confirmation of "+
"ChannelPoint(%v)", completeChan.FundingOutpoint)