Skip to content

Commit

Permalink
Fix: always check inclusionTime before triggering TransactionConfirme…
Browse files Browse the repository at this point in the history
…d event
  • Loading branch information
karimodm committed Jun 28, 2022
1 parent 36b11ab commit 2287d1e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand All @@ -252,7 +252,7 @@ func (l *Ledger) propagatedConfirmationToIncludedTransactions(txID utxo.Transact
return
}

if !l.triggerConfirmedEvent(consumingTxMetadata, true) {
if !l.triggerConfirmedEvent(consumingTxMetadata) {
return
}

Expand Down

0 comments on commit 2287d1e

Please sign in to comment.