chainntnfs: Fix btcdnotify dispatch race condition
This race condition can occur if a transaction is included in a block right when a notification is being added to the notifier for it AND when the confirmation requires > 1 confirmations. In this case, the confirmation gets added to the confirmation heap twice.
This commit is contained in:
parent
b3509d491a
commit
93981a85c0
@ -418,6 +418,8 @@ out:
|
||||
// attemptHistoricalDispatch tries to use historical information to decide if a
|
||||
// notification ca be dispatched immediately, or is partially confirmed so it
|
||||
// can skip straight to the confirmations heap.
|
||||
//
|
||||
// Returns true if the transaction was either partially or completely confirmed
|
||||
func (b *BtcdNotifier) attemptHistoricalDispatch(msg *confirmationsNotification,
|
||||
currentHeight int32) bool {
|
||||
|
||||
@ -489,7 +491,7 @@ func (b *BtcdNotifier) attemptHistoricalDispatch(msg *confirmationsNotification,
|
||||
}
|
||||
heap.Push(b.confHeap, heapEntry)
|
||||
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
// notifyBlockEpochs notifies all registered block epoch clients of the newly
|
||||
|
Loading…
Reference in New Issue
Block a user