Skip to content

Commit

Permalink
Moved the MemPool events into a new Ledger events struct
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsporn committed Mar 10, 2023
1 parent 46b4823 commit 0b8c7f3
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 35 deletions.
4 changes: 2 additions & 2 deletions packages/protocol/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,12 @@ func (e *Engine) setupNotarizationManager() {
wpCommitments := e.Workers.CreatePool("NotarizationManager.Commitments", 1) // Using just 1 worker to avoid contention

// SlotMutations must be hooked because inclusion might be added before transaction are added.
e.Events.MemPool.TransactionAccepted.Hook(func(event *mempool.TransactionEvent) {
e.Events.Ledger.MemPool.TransactionAccepted.Hook(func(event *mempool.TransactionEvent) {
if err := e.NotarizationManager.SlotMutations.AddAcceptedTransaction(event.Metadata); err != nil {
e.Events.Error.Trigger(errors.Wrapf(err, "failed to add accepted transaction %s to slot", event.Metadata.ID()))
}
})
e.Events.MemPool.TransactionInclusionUpdated.Hook(func(event *mempool.TransactionInclusionUpdatedEvent) {
e.Events.Ledger.MemPool.TransactionInclusionUpdated.Hook(func(event *mempool.TransactionInclusionUpdatedEvent) {
if err := e.NotarizationManager.SlotMutations.UpdateTransactionInclusion(event.TransactionID, event.PreviousInclusionSlot, event.InclusionSlot); err != nil {
e.Events.Error.Trigger(errors.Wrapf(err, "failed to update transaction inclusion time %s in slot", event.TransactionID))
}
Expand Down
6 changes: 3 additions & 3 deletions packages/protocol/engine/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/iotaledger/goshimmer/packages/protocol/engine/consensus"
"github.com/iotaledger/goshimmer/packages/protocol/engine/eviction"
"github.com/iotaledger/goshimmer/packages/protocol/engine/filter"
"github.com/iotaledger/goshimmer/packages/protocol/engine/ledger/mempool"
"github.com/iotaledger/goshimmer/packages/protocol/engine/ledger"
"github.com/iotaledger/goshimmer/packages/protocol/engine/notarization"
"github.com/iotaledger/goshimmer/packages/protocol/engine/tangle"
"github.com/iotaledger/goshimmer/packages/protocol/models"
Expand All @@ -19,7 +19,7 @@ type Events struct {

EvictionState *eviction.Events
Filter *filter.Events
MemPool *mempool.Events
Ledger *ledger.Events
Tangle *tangle.Events
Consensus *consensus.Events
Clock *clock.Events
Expand All @@ -37,7 +37,7 @@ var NewEvents = event.CreateGroupConstructor(func() (newEvents *Events) {
BlockProcessed: event.New1[models.BlockID](),
EvictionState: eviction.NewEvents(),
Filter: filter.NewEvents(),
MemPool: mempool.NewEvents(),
Ledger: ledger.NewEvents(),
Tangle: tangle.NewEvents(),
Consensus: consensus.NewEvents(),
Clock: clock.NewEvents(),
Expand Down
21 changes: 21 additions & 0 deletions packages/protocol/engine/ledger/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ledger

import (
"github.com/iotaledger/goshimmer/packages/protocol/engine/ledger/mempool"
"github.com/iotaledger/hive.go/runtime/event"
)

// Events is a container that acts as a dictionary for the existing events of a MemPool.
type Events struct {
// MemPool contains all mempool related events.
MemPool *mempool.Events

event.Group[Events, *Events]
}

// NewEvents contains the constructor of the Events object (it is generated by a generic factory).
var NewEvents = event.CreateGroupConstructor(func() (newEvents *Events) {
return &Events{
MemPool: mempool.NewEvents(),
}
})
4 changes: 4 additions & 0 deletions packages/protocol/engine/ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (

// Ledger is an engine module that provides access to the persistent ledger state.
type Ledger interface {
// Events is a dictionary for Ledger related events.
Events() *Events

// MemPool returns the MemPool implementation used by this ledger.
MemPool() mempool.MemPool

// UnspentOutputs returns the unspent outputs of the ledger state.
Expand Down
4 changes: 4 additions & 0 deletions packages/protocol/engine/ledger/mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ type MemPool interface {
// Events is a dictionary for MemPool related events.
Events() *Events

// Storage provides access to the stored models inside the MemPool.
Storage() Storage

// Utils provides various helpers to access the MemPool.
Utils() Utils

// ConflictDAG is a reference to the ConflictDAG that is used by this MemPool.
Expand All @@ -37,8 +39,10 @@ type MemPool interface {
// CheckTransaction checks the validity of a Transaction.
CheckTransaction(ctx context.Context, tx utxo.Transaction) (err error)

// VM is the vm used for transaction validation.
VM() vm.VM

// Shutdown should be called when the module is stopped.
Shutdown()

module.Interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func NewProvider(opts ...options.Option[RealitiesLedger]) module.Provider[*engin

e.HookConstructed(func() {
l.Initialize(e.Workers.CreatePool("MemPool", 2), e.Storage)
e.Events.MemPool.LinkTo(l.events)
})

return l
Expand Down
12 changes: 10 additions & 2 deletions packages/protocol/engine/ledger/utxoledger/utxoledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

// UTXOLedger represents a ledger using the realities based mempool.
type UTXOLedger struct {
events *ledger.Events
engine *engine.Engine
memPool mempool.MemPool
unspentOutputs *UnspentOutputs
Expand All @@ -32,21 +33,24 @@ type UTXOLedger struct {
func NewProvider(opts ...options.Option[UTXOLedger]) module.Provider[*engine.Engine, ledger.Ledger] {
return module.Provide(func(e *engine.Engine) ledger.Ledger {
return options.Apply(&UTXOLedger{
events: ledger.NewEvents(),
engine: e,
stateDiffs: NewStateDiffs(e),
unspentOutputs: NewUnspentOutputs(e),
optsMemPoolProvider: realitiesledger.NewProvider(),
}, opts, func(l *UTXOLedger) {
l.memPool = l.optsMemPoolProvider(e)
l.events.MemPool.LinkTo(l.memPool.Events())

e.HookConstructed(func() {
e.Events.Ledger.LinkTo(l.events)
e.HookStopped(l.memPool.Shutdown)

l.HookInitialized(l.unspentOutputs.TriggerInitialized)

l.HookStopped(lo.Batch(
e.Events.MemPool.TransactionAccepted.Hook(l.onTransactionAccepted).Unhook,
e.Events.MemPool.TransactionInclusionUpdated.Hook(l.onTransactionInclusionUpdated).Unhook,
e.Events.Ledger.MemPool.TransactionAccepted.Hook(l.onTransactionAccepted).Unhook,
e.Events.Ledger.MemPool.TransactionInclusionUpdated.Hook(l.onTransactionInclusionUpdated).Unhook,
))
})

Expand All @@ -55,6 +59,10 @@ func NewProvider(opts ...options.Option[UTXOLedger]) module.Provider[*engine.Eng
})
}

func (l *UTXOLedger) Events() *ledger.Events {
return l.events
}

func (l *UTXOLedger) MemPool() mempool.MemPool {
return l.memPool
}
Expand Down
6 changes: 3 additions & 3 deletions packages/protocol/tipmanager/tipsconflicttracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ func NewTipsConflictTracker(workerPool *workerpool.WorkerPool, engineInstance *e
}

func (c *TipsConflictTracker) setup() {
c.engine.Events.MemPool.ConflictDAG.ConflictAccepted.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
c.engine.Events.Ledger.MemPool.ConflictDAG.ConflictAccepted.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
c.deleteConflict(conflict.ID())
}, event.WithWorkerPool(c.workerPool))
c.engine.Events.MemPool.ConflictDAG.ConflictRejected.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
c.engine.Events.Ledger.MemPool.ConflictDAG.ConflictRejected.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
c.deleteConflict(conflict.ID())
}, event.WithWorkerPool(c.workerPool))
c.engine.Events.MemPool.ConflictDAG.ConflictNotConflicting.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
c.engine.Events.Ledger.MemPool.ConflictDAG.ConflictNotConflicting.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
c.deleteConflict(conflict.ID())
}, event.WithWorkerPool(c.workerPool))
}
Expand Down
10 changes: 5 additions & 5 deletions plugins/dagsvisualizer/visualizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func registerTangleEvents(plugin *node.Plugin) {
storeWsBlock(wsBlk)
}, event.WithWorkerPool(plugin.WorkerPool))

deps.Protocol.Events.Engine.MemPool.TransactionAccepted.Hook(func(event *mempool.TransactionEvent) {
deps.Protocol.Events.Engine.Ledger.MemPool.TransactionAccepted.Hook(func(event *mempool.TransactionEvent) {
attachmentBlock := deps.Protocol.Engine().Tangle.Booker.GetEarliestAttachment(event.Metadata.ID())

wsBlk := &wsBlock{
Expand Down Expand Up @@ -132,7 +132,7 @@ func registerUTXOEvents(plugin *node.Plugin) {
}
}, event.WithWorkerPool(plugin.WorkerPool))

deps.Protocol.Events.Engine.MemPool.TransactionAccepted.Hook(func(event *mempool.TransactionEvent) {
deps.Protocol.Events.Engine.Ledger.MemPool.TransactionAccepted.Hook(func(event *mempool.TransactionEvent) {
txMeta := event.Metadata
wsBlk := &wsBlock{
Type: BlkTypeUTXOConfirmationStateChanged,
Expand Down Expand Up @@ -163,7 +163,7 @@ func registerConflictEvents(plugin *node.Plugin) {
storeWsBlock(wsBlk)
}

deps.Protocol.Events.Engine.MemPool.ConflictDAG.ConflictCreated.Hook(func(event *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
deps.Protocol.Events.Engine.Ledger.MemPool.ConflictDAG.ConflictCreated.Hook(func(event *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
wsBlk := &wsBlock{
Type: BlkTypeConflictVertex,
Data: newConflictVertex(event.ID()),
Expand All @@ -172,7 +172,7 @@ func registerConflictEvents(plugin *node.Plugin) {
storeWsBlock(wsBlk)
}, event.WithWorkerPool(plugin.WorkerPool))

deps.Protocol.Events.Engine.MemPool.ConflictDAG.ConflictAccepted.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
deps.Protocol.Events.Engine.Ledger.MemPool.ConflictDAG.ConflictAccepted.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
wsBlk := &wsBlock{
Type: BlkTypeConflictConfirmationStateChanged,
Data: &conflictConfirmationStateChanged{
Expand All @@ -185,7 +185,7 @@ func registerConflictEvents(plugin *node.Plugin) {
storeWsBlock(wsBlk)
}, event.WithWorkerPool(plugin.WorkerPool))

deps.Protocol.Events.Engine.MemPool.ConflictDAG.ConflictParentsUpdated.Hook(func(event *conflictdag.ConflictParentsUpdatedEvent[utxo.TransactionID, utxo.OutputID]) {
deps.Protocol.Events.Engine.Ledger.MemPool.ConflictDAG.ConflictParentsUpdated.Hook(func(event *conflictdag.ConflictParentsUpdatedEvent[utxo.TransactionID, utxo.OutputID]) {
lo.Map(event.ParentsConflictIDs.Slice(), utxo.TransactionID.Base58)
wsBlk := &wsBlock{
Type: BlkTypeConflictParentsUpdate,
Expand Down
6 changes: 3 additions & 3 deletions plugins/dashboard/conflicts_livefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ func runConflictLiveFeed(plugin *node.Plugin) {
}

unhook := lo.Batch(
deps.Protocol.Events.Engine.MemPool.ConflictDAG.ConflictCreated.Hook(onConflictCreated, event.WithWorkerPool(plugin.WorkerPool)).Unhook,
deps.Protocol.Events.Engine.MemPool.ConflictDAG.ConflictAccepted.Hook(onConflictAccepted, event.WithWorkerPool(plugin.WorkerPool)).Unhook,
deps.Protocol.Events.Engine.MemPool.ConflictDAG.ConflictRejected.Hook(onConflictRejected, event.WithWorkerPool(plugin.WorkerPool)).Unhook,
deps.Protocol.Events.Engine.Ledger.MemPool.ConflictDAG.ConflictCreated.Hook(onConflictCreated, event.WithWorkerPool(plugin.WorkerPool)).Unhook,
deps.Protocol.Events.Engine.Ledger.MemPool.ConflictDAG.ConflictAccepted.Hook(onConflictAccepted, event.WithWorkerPool(plugin.WorkerPool)).Unhook,
deps.Protocol.Events.Engine.Ledger.MemPool.ConflictDAG.ConflictRejected.Hook(onConflictRejected, event.WithWorkerPool(plugin.WorkerPool)).Unhook,
)

<-ctx.Done()
Expand Down
6 changes: 3 additions & 3 deletions plugins/indexer/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func provide(protocol *protocol.Protocol) (i *indexer.Indexer) {
}

func configure(plugin *node.Plugin) {
deps.Protocol.Events.Engine.MemPool.OutputCreated.Hook(deps.Indexer.OnOutputCreated, event.WithWorkerPool(plugin.WorkerPool))
deps.Protocol.Events.Engine.MemPool.OutputSpent.Hook(deps.Indexer.OnOutputSpentRejected, event.WithWorkerPool(plugin.WorkerPool))
deps.Protocol.Events.Engine.MemPool.OutputRejected.Hook(deps.Indexer.OnOutputSpentRejected, event.WithWorkerPool(plugin.WorkerPool))
deps.Protocol.Events.Engine.Ledger.MemPool.OutputCreated.Hook(deps.Indexer.OnOutputCreated, event.WithWorkerPool(plugin.WorkerPool))
deps.Protocol.Events.Engine.Ledger.MemPool.OutputSpent.Hook(deps.Indexer.OnOutputSpentRejected, event.WithWorkerPool(plugin.WorkerPool))
deps.Protocol.Events.Engine.Ledger.MemPool.OutputRejected.Hook(deps.Indexer.OnOutputSpentRejected, event.WithWorkerPool(plugin.WorkerPool))
}
6 changes: 3 additions & 3 deletions plugins/metrics/metrics_conflicts.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var ConflictMetrics = collector.NewCollection(conflictNamespace,
collector.WithType(collector.Counter),
collector.WithHelp("Time since transaction issuance to the conflict acceptance"),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.MemPool.ConflictDAG.ConflictAccepted.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
deps.Protocol.Events.Engine.Ledger.MemPool.ConflictDAG.ConflictAccepted.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
firstAttachment := deps.Protocol.Engine().Tangle.Booker.GetEarliestAttachment(conflict.ID())
timeSinceIssuance := time.Since(firstAttachment.IssuingTime()).Milliseconds()
timeIssuanceSeconds := float64(timeSinceIssuance) / 1000
Expand All @@ -34,7 +34,7 @@ var ConflictMetrics = collector.NewCollection(conflictNamespace,
collector.WithType(collector.Counter),
collector.WithHelp("Number of resolved (accepted) conflicts"),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.MemPool.ConflictDAG.ConflictAccepted.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
deps.Protocol.Events.Engine.Ledger.MemPool.ConflictDAG.ConflictAccepted.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
deps.Collector.Increment(conflictNamespace, resolvedConflictCount)
}, event.WithWorkerPool(Plugin.WorkerPool))
}),
Expand All @@ -43,7 +43,7 @@ var ConflictMetrics = collector.NewCollection(conflictNamespace,
collector.WithType(collector.Counter),
collector.WithHelp("Number of created conflicts"),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.MemPool.ConflictDAG.ConflictCreated.Hook(func(event *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
deps.Protocol.Events.Engine.Ledger.MemPool.ConflictDAG.ConflictCreated.Hook(func(event *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
deps.Collector.Increment(conflictNamespace, allConflictCounts)
}, event.WithWorkerPool(Plugin.WorkerPool))
}),
Expand Down
12 changes: 6 additions & 6 deletions plugins/metrics/metrics_slots.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ var SlotMetrics = collector.NewCollection(slotNamespace,
collector.WithLabels(labelName),
collector.WithHelp("Number of rejected attachments by the node per slot."),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.MemPool.TransactionRejected.Hook(func(transactionMetadata *mempool.TransactionMetadata) {
deps.Protocol.Events.Engine.Ledger.MemPool.TransactionRejected.Hook(func(transactionMetadata *mempool.TransactionMetadata) {
for it := deps.Protocol.Engine().Tangle.Booker.GetAllAttachments(transactionMetadata.ID()).Iterator(); it.HasNext(); {
attachmentBlock := it.Next()
if !attachmentBlock.IsOrphaned() {
Expand All @@ -157,7 +157,7 @@ var SlotMetrics = collector.NewCollection(slotNamespace,
collector.WithLabels(labelName),
collector.WithHelp("Number of accepted attachments by the node per slot."),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.MemPool.TransactionAccepted.Hook(func(transactionEvent *mempool.TransactionEvent) {
deps.Protocol.Events.Engine.Ledger.MemPool.TransactionAccepted.Hook(func(transactionEvent *mempool.TransactionEvent) {
for it := deps.Protocol.Engine().Tangle.Booker.GetAllAttachments(transactionEvent.Metadata.ID()).Iterator(); it.HasNext(); {
attachmentBlock := it.Next()
if !attachmentBlock.IsOrphaned() {
Expand All @@ -172,7 +172,7 @@ var SlotMetrics = collector.NewCollection(slotNamespace,
collector.WithLabels(labelName),
collector.WithHelp("Number of conflicts created per slot."),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.MemPool.ConflictDAG.ConflictCreated.Hook(func(conflictCreated *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
deps.Protocol.Events.Engine.Ledger.MemPool.ConflictDAG.ConflictCreated.Hook(func(conflictCreated *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
for it := deps.Protocol.Engine().Tangle.Booker.GetAllAttachments(conflictCreated.ID()).Iterator(); it.HasNext(); {
deps.Collector.Increment(slotNamespace, createdConflicts, strconv.Itoa(int(it.Next().ID().Index())))
}
Expand All @@ -184,7 +184,7 @@ var SlotMetrics = collector.NewCollection(slotNamespace,
collector.WithLabels(labelName),
collector.WithHelp("Number of conflicts accepted per slot."),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.MemPool.ConflictDAG.ConflictAccepted.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
deps.Protocol.Events.Engine.Ledger.MemPool.ConflictDAG.ConflictAccepted.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
for it := deps.Protocol.Engine().Tangle.Booker.GetAllAttachments(conflict.ID()).Iterator(); it.HasNext(); {
deps.Collector.Increment(slotNamespace, acceptedConflicts, strconv.Itoa(int(it.Next().ID().Index())))
}
Expand All @@ -196,7 +196,7 @@ var SlotMetrics = collector.NewCollection(slotNamespace,
collector.WithLabels(labelName),
collector.WithHelp("Number of conflicts rejected per slot."),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.MemPool.ConflictDAG.ConflictRejected.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
deps.Protocol.Events.Engine.Ledger.MemPool.ConflictDAG.ConflictRejected.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
for it := deps.Protocol.Engine().Tangle.Booker.GetAllAttachments(conflict.ID()).Iterator(); it.HasNext(); {
deps.Collector.Increment(slotNamespace, rejectedConflicts, strconv.Itoa(int(it.Next().ID().Index())))
}
Expand All @@ -208,7 +208,7 @@ var SlotMetrics = collector.NewCollection(slotNamespace,
collector.WithLabels(labelName),
collector.WithHelp("Number of conflicts rejected per slot."),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.MemPool.ConflictDAG.ConflictNotConflicting.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
deps.Protocol.Events.Engine.Ledger.MemPool.ConflictDAG.ConflictNotConflicting.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
for it := deps.Protocol.Engine().Tangle.Booker.GetAllAttachments(conflict.ID()).Iterator(); it.HasNext(); {
deps.Collector.Increment(slotNamespace, notConflictingConflicts, strconv.Itoa(int(it.Next().ID().Index())))
}
Expand Down
6 changes: 3 additions & 3 deletions plugins/remotemetrics/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ func configureConflictConfirmationMetrics(plugin *node.Plugin) {
return
}

deps.Protocol.Events.Engine.MemPool.ConflictDAG.ConflictAccepted.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
deps.Protocol.Events.Engine.Ledger.MemPool.ConflictDAG.ConflictAccepted.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
onConflictConfirmed(conflict.ID())
}, event.WithWorkerPool(plugin.WorkerPool))

deps.Protocol.Events.Engine.MemPool.ConflictDAG.ConflictCreated.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
deps.Protocol.Events.Engine.Ledger.MemPool.ConflictDAG.ConflictCreated.Hook(func(conflict *conflictdag.Conflict[utxo.TransactionID, utxo.OutputID]) {
activeConflictsMutex.Lock()
defer activeConflictsMutex.Unlock()

Expand All @@ -151,7 +151,7 @@ func configureBlockFinalizedMetrics(plugin *node.Plugin) {
}

if Parameters.MetricsLevel == Info {
deps.Protocol.Events.Engine.MemPool.TransactionAccepted.Hook(onTransactionAccepted, event.WithWorkerPool(plugin.WorkerPool))
deps.Protocol.Events.Engine.Ledger.MemPool.TransactionAccepted.Hook(onTransactionAccepted, event.WithWorkerPool(plugin.WorkerPool))
} else {
deps.Protocol.Events.Engine.Consensus.BlockGadget.BlockConfirmed.Hook(func(block *blockgadget.Block) {
onBlockFinalized(block.ModelsBlock)
Expand Down
2 changes: 1 addition & 1 deletion plugins/webapi/ledgerstate/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func FilterRemove(txID utxo.TransactionID) {
func configure(plugin *node.Plugin) {
if webapi.Parameters.EnableDSFilter {
doubleSpendFilter = Filter()
deps.Protocol.Events.Engine.MemPool.TransactionAccepted.Hook(func(event *mempool.TransactionEvent) {
deps.Protocol.Events.Engine.Ledger.MemPool.TransactionAccepted.Hook(func(event *mempool.TransactionEvent) {
doubleSpendFilter.Remove(event.Metadata.ID())
}, event.WithWorkerPool(plugin.WorkerPool))
}
Expand Down

0 comments on commit 0b8c7f3

Please sign in to comment.