Skip to content

Commit

Permalink
Hook to TransactionMetadata OnRejected to capture conflicting reason …
Browse files Browse the repository at this point in the history
…correctly
  • Loading branch information
jkrvivian committed Nov 8, 2023
1 parent e01553a commit 02fb2f7
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions pkg/retainer/retainer/retainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,6 @@ func NewProvider() module.Provider[*engine.Engine, retainer.Retainer] {
r.RetainBlockFailure(b.ID(), apimodels.BlockFailureDroppedDueToCongestion)
})

e.Events.SpendDAG.SpendRejected.Hook(func(spendID iotago.TransactionID) {
txMetadata, exist := e.Ledger.MemPool().TransactionMetadata(spendID)
if !exist {
return
}
r.RetainTransactionFailure(txMetadata.EarliestIncludedAttachment(), iotago.ErrTxConflicting)
}, asyncOpt)

e.HookInitialized(func() {
e.Ledger.MemPool().OnSignedTransactionAttached(func(signedTransactionMetadata mempool.SignedTransactionMetadata) {
attachment := signedTransactionMetadata.Attachments()[0]
Expand All @@ -116,6 +108,10 @@ func NewProvider() module.Provider[*engine.Engine, retainer.Retainer] {
r.RetainTransactionFailure(attachment, err)
})

transactionMetadata.OnRejected(func() {
r.RetainTransactionFailure(attachment, iotago.ErrTxConflicting)
})

transactionMetadata.OnAccepted(func() {
attachmentID := transactionMetadata.EarliestIncludedAttachment()
if slot := attachmentID.Slot(); slot > 0 {
Expand Down

0 comments on commit 02fb2f7

Please sign in to comment.