utxonursery: use a two value read from the epoch chan for graceful shutdown
Within the utoxNursery we now use a two value read fro the block epoch channel in order to exit early if/when the ChainNotifier begins the shutdown process before the signal reaches the utxoNursery.
This commit is contained in:
parent
f29b496b76
commit
343cd7779f
|
@ -96,6 +96,8 @@ func (u *utxoNursery) Stop() error {
|
||||||
// Once an output is mature, it will be swept into the wallet at the earlier
|
// Once an output is mature, it will be swept into the wallet at the earlier
|
||||||
// possible height.
|
// possible height.
|
||||||
func (u *utxoNursery) incubator() {
|
func (u *utxoNursery) incubator() {
|
||||||
|
defer u.wg.Done()
|
||||||
|
|
||||||
// Register with the notifier to receive notifications for each newly
|
// Register with the notifier to receive notifications for each newly
|
||||||
// connected block.
|
// connected block.
|
||||||
newBlocks, err := u.notifier.RegisterBlockEpochNtfn()
|
newBlocks, err := u.notifier.RegisterBlockEpochNtfn()
|
||||||
|
@ -163,7 +165,15 @@ out:
|
||||||
utxnLog.Infof("Outpoint %v now mid-stage, will mature "+
|
utxnLog.Infof("Outpoint %v now mid-stage, will mature "+
|
||||||
"at height %v (delay of %v)", midUtxo.outPoint,
|
"at height %v (delay of %v)", midUtxo.outPoint,
|
||||||
maturityHeight, midUtxo.blocksToMaturity)
|
maturityHeight, midUtxo.blocksToMaturity)
|
||||||
case epoch := <-newBlocks.Epochs:
|
case epoch, ok := <-newBlocks.Epochs:
|
||||||
|
// If the epoch channel has been closed, then the
|
||||||
|
// ChainNotifier is exiting which means the daemon is
|
||||||
|
// as well. Therefore, we exit early also in order to
|
||||||
|
// ensure the daemon shutsdown gracefully, yet swiftly.
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// A new block has just been connected, check to see if
|
// A new block has just been connected, check to see if
|
||||||
// we have any new outputs that can be swept into the
|
// we have any new outputs that can be swept into the
|
||||||
// wallet.
|
// wallet.
|
||||||
|
@ -210,8 +220,6 @@ out:
|
||||||
break out
|
break out
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u.wg.Done()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// createSweepTx creates a final sweeping transaction with all witnesses in
|
// createSweepTx creates a final sweeping transaction with all witnesses in
|
||||||
|
|
Loading…
Reference in New Issue
Block a user