From 2287d1efde838cff127d9052df97d74ecbaeefce Mon Sep 17 00:00:00 2001 From: Andrea V <1577639+karimodm@users.noreply.github.com> Date: Tue, 28 Jun 2022 12:50:32 +0200 Subject: [PATCH] Fix: always check inclusionTime before triggering TransactionConfirmed event --- packages/ledger/ledger.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/ledger/ledger.go b/packages/ledger/ledger.go index 8ebf2a9c43..d11d6a0830 100644 --- a/packages/ledger/ledger.go +++ b/packages/ledger/ledger.go @@ -146,7 +146,7 @@ func (l *Ledger) SetTransactionInclusionTime(txID utxo.TransactionID, inclusionT }) if previousInclusionTime.IsZero() && l.ConflictDAG.InclusionState(txMetadata.BranchIDs()) == conflictdag.Confirmed { - l.triggerConfirmedEvent(txMetadata, false) + l.triggerConfirmedEvent(txMetadata) } }) } @@ -198,8 +198,8 @@ func (l *Ledger) processConsumingTransactions(outputIDs utxo.OutputIDs) { } // triggerConfirmedEvent triggers the TransactionConfirmed event if the Transaction was confirmed. -func (l *Ledger) triggerConfirmedEvent(txMetadata *TransactionMetadata, checkInclusion bool) (triggered bool) { - if checkInclusion && txMetadata.InclusionTime().IsZero() { +func (l *Ledger) triggerConfirmedEvent(txMetadata *TransactionMetadata) (triggered bool) { + if txMetadata.InclusionTime().IsZero() { return false } @@ -243,7 +243,7 @@ func (l *Ledger) triggerRejectedEvent(txMetadata *TransactionMetadata) (triggere // Transaction. func (l *Ledger) propagatedConfirmationToIncludedTransactions(txID utxo.TransactionID) { l.Storage.CachedTransactionMetadata(txID).Consume(func(txMetadata *TransactionMetadata) { - if !l.triggerConfirmedEvent(txMetadata, false) { + if !l.triggerConfirmedEvent(txMetadata) { return } @@ -252,7 +252,7 @@ func (l *Ledger) propagatedConfirmationToIncludedTransactions(txID utxo.Transact return } - if !l.triggerConfirmedEvent(consumingTxMetadata, true) { + if !l.triggerConfirmedEvent(consumingTxMetadata) { return }