chainntnfs/tx_notifier: remove cached conf details on reorg
In this commit, we address a small bug where it's possible to deliver a confirmation notification with stale confirmation details upon registration. This can happen if a transaction has confirmed but was reorged out of the chain later on, and a subsequent notification is registered.
This commit is contained in:
parent
b28145b69e
commit
5ae8243d0d
@ -687,7 +687,15 @@ func (tcn *TxConfNotifier) DisconnectTip(blockHeight uint32) error {
|
|||||||
// clients is always non-blocking.
|
// clients is always non-blocking.
|
||||||
for initialHeight, txHashes := range tcn.txsByInitialHeight {
|
for initialHeight, txHashes := range tcn.txsByInitialHeight {
|
||||||
for txHash := range txHashes {
|
for txHash := range txHashes {
|
||||||
|
// If the transaction has been reorged out of the chain,
|
||||||
|
// we'll make sure to remove the cached confirmation
|
||||||
|
// details to prevent notifying clients with old
|
||||||
|
// information.
|
||||||
confSet := tcn.confNotifications[txHash]
|
confSet := tcn.confNotifications[txHash]
|
||||||
|
if initialHeight == blockHeight {
|
||||||
|
confSet.details = nil
|
||||||
|
}
|
||||||
|
|
||||||
for _, ntfn := range confSet.ntfns {
|
for _, ntfn := range confSet.ntfns {
|
||||||
// First, we'll attempt to drain an update
|
// First, we'll attempt to drain an update
|
||||||
// from each notification to ensure sends to the
|
// from each notification to ensure sends to the
|
||||||
|
Loading…
Reference in New Issue
Block a user