chainntnfs/bitcoind: move NotifySpent to after recording the outpoint
This commit moves the call to the bitcoind backend to start watching an outpoint for spentness to after we have recorded the outpoint in our list of clients. This is done to avoid a race that we saw using the btcd backend, and it is probable that it can also happen using bitcoind.
This commit is contained in:
parent
b08fc05390
commit
13be19c9ec
@ -488,10 +488,6 @@ type spendCancel struct {
|
||||
func (b *BitcoindNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
|
||||
_ uint32) (*chainntnfs.SpendEvent, error) {
|
||||
|
||||
if err := b.chainConn.NotifySpent([]*wire.OutPoint{outpoint}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ntfn := &spendNotification{
|
||||
targetOutpoint: outpoint,
|
||||
spendChan: make(chan *chainntnfs.SpendDetail, 1),
|
||||
@ -504,6 +500,10 @@ func (b *BitcoindNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
|
||||
case b.notificationRegistry <- ntfn:
|
||||
}
|
||||
|
||||
if err := b.chainConn.NotifySpent([]*wire.OutPoint{outpoint}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// The following conditional checks to ensure that when a spend notification
|
||||
// is registered, the output hasn't already been spent. If the output
|
||||
// is no longer in the UTXO set, the chain will be rescanned from the point
|
||||
|
Loading…
Reference in New Issue
Block a user