From 83946c4b2632b4e38b8bb17972cda95ee1828122 Mon Sep 17 00:00:00 2001 From: Alexander Sporn Date: Mon, 29 Apr 2024 11:03:20 +0200 Subject: [PATCH] Fixed trace logs --- pkg/protocol/engine/engine.go | 98 +++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 46 deletions(-) diff --git a/pkg/protocol/engine/engine.go b/pkg/protocol/engine/engine.go index 63df3bcf2..4865f8810 100644 --- a/pkg/protocol/engine/engine.go +++ b/pkg/protocol/engine/engine.go @@ -770,53 +770,59 @@ func (e *Engine) attachEngineLogs() (teardown func()) { logMessage("SpendDAG.SpenderAccepted", "conflictID", conflictID) }).Unhook, - e.Ledger.OnTransactionAttached(func(transactionMetadata mempool.TransactionMetadata) { - logMessage("Ledger.TransactionAttached", "tx", transactionMetadata.ID()) - - transactionMetadata.OnSolid(func() { - logMessage("MemPool.TransactionSolid", "tx", transactionMetadata.ID()) - }) - - transactionMetadata.OnExecuted(func() { - logMessage("MemPool.TransactionExecuted", "tx", transactionMetadata.ID()) - }) - - transactionMetadata.OnBooked(func() { - logMessage("MemPool.TransactionBooked", "tx", transactionMetadata.ID()) + e.ConstructedEvent().WithNonEmptyValue(func(_ bool) func() { + return e.Ledger.InitializedEvent().WithNonEmptyValue(func(_ bool) func() { + return lo.Batch( + e.Ledger.OnTransactionAttached(func(transactionMetadata mempool.TransactionMetadata) { + logMessage("Ledger.TransactionAttached", "tx", transactionMetadata.ID()) + + transactionMetadata.OnSolid(func() { + logMessage("MemPool.TransactionSolid", "tx", transactionMetadata.ID()) + }) + + transactionMetadata.OnExecuted(func() { + logMessage("MemPool.TransactionExecuted", "tx", transactionMetadata.ID()) + }) + + transactionMetadata.OnBooked(func() { + logMessage("MemPool.TransactionBooked", "tx", transactionMetadata.ID()) + }) + + transactionMetadata.OnAccepted(func() { + logMessage("MemPool.TransactionAccepted", "tx", transactionMetadata.ID()) + }) + + transactionMetadata.OnRejected(func() { + logMessage("MemPool.TransactionRejected", "tx", transactionMetadata.ID()) + }) + + transactionMetadata.OnInvalid(func(err error) { + logMessage("MemPool.TransactionInvalid", "tx", transactionMetadata.ID(), "err", err) + }) + + transactionMetadata.OnOrphanedSlotUpdated(func(slot iotago.SlotIndex) { + logMessage("MemPool.TransactionOrphanedSlotUpdated", "tx", transactionMetadata.ID(), "slot", slot) + }) + + transactionMetadata.OnCommittedSlotUpdated(func(slot iotago.SlotIndex) { + logMessage("MemPool.TransactionCommittedSlotUpdated", "tx", transactionMetadata.ID(), "slot", slot) + }) + + transactionMetadata.OnEvicted(func() { + logMessage("MemPool.TransactionEvicted", "tx", transactionMetadata.ID()) + }) + }).Unhook, + + e.Ledger.MemPool().OnSignedTransactionAttached( + func(signedTransactionMetadata mempool.SignedTransactionMetadata) { + signedTransactionMetadata.OnSignaturesInvalid(func(err error) { + logMessage("MemPool.SignedTransactionSignaturesInvalid", "signedTx", signedTransactionMetadata.ID(), "tx", signedTransactionMetadata.TransactionMetadata().ID(), "err", err) + }) + }, + ).Unhook, + ) }) - - transactionMetadata.OnAccepted(func() { - logMessage("MemPool.TransactionAccepted", "tx", transactionMetadata.ID()) - }) - - transactionMetadata.OnRejected(func() { - logMessage("MemPool.TransactionRejected", "tx", transactionMetadata.ID()) - }) - - transactionMetadata.OnInvalid(func(err error) { - logMessage("MemPool.TransactionInvalid", "tx", transactionMetadata.ID(), "err", err) - }) - - transactionMetadata.OnOrphanedSlotUpdated(func(slot iotago.SlotIndex) { - logMessage("MemPool.TransactionOrphanedSlotUpdated", "tx", transactionMetadata.ID(), "slot", slot) - }) - - transactionMetadata.OnCommittedSlotUpdated(func(slot iotago.SlotIndex) { - logMessage("MemPool.TransactionCommittedSlotUpdated", "tx", transactionMetadata.ID(), "slot", slot) - }) - - transactionMetadata.OnEvicted(func() { - logMessage("MemPool.TransactionEvicted", "tx", transactionMetadata.ID()) - }) - }).Unhook, - - e.Ledger.MemPool().OnSignedTransactionAttached( - func(signedTransactionMetadata mempool.SignedTransactionMetadata) { - signedTransactionMetadata.OnSignaturesInvalid(func(err error) { - logMessage("MemPool.SignedTransactionSignaturesInvalid", "signedTx", signedTransactionMetadata.ID(), "tx", signedTransactionMetadata.TransactionMetadata().ID(), "err", err) - }) - }, - ).Unhook, + }), ) }),