Skip to content

Commit

Permalink
Merge pull request #820 from iotaledger/fix/retainer-events
Browse files Browse the repository at this point in the history
Fixed Retainer.BlockRetained event not being linked to the block retainer
  • Loading branch information
alexsporn authored Mar 8, 2024
2 parents b03ce6a + 24e761c commit 8aa624f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/protocol/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ func attachEngineLogs(instance *engine.Engine) func() {
instance.LogTrace("BlockProcessed", "block", blockID)
}).Unhook,

events.Retainer.BlockRetained.Hook(func(block *blocks.Block) {
instance.LogTrace("Retainer.BlockRetained", "block", block.ID())
}).Unhook,

events.Notarization.SlotCommitted.Hook(func(details *notarization.SlotCommittedDetails) {
instance.LogTrace("NotarizationManager.SlotCommitted", "commitment", details.Commitment.ID(), "acceptedBlocks count", details.AcceptedBlocks.Size(), "accepted transactions", len(details.Mutations))
}).Unhook,
Expand Down
4 changes: 2 additions & 2 deletions pkg/requesthandler/blockissuance.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (r *RequestHandler) SubmitBlockAndAwaitEvent(ctx context.Context, block *mo
case <-exit:
}
}, event.WithWorkerPool(r.workerPool)).Unhook

postfilteredUnhook := r.protocol.Events.Engine.PostSolidFilter.BlockFiltered.Hook(func(event *postsolidfilter.BlockFilteredEvent) {
if blockID != event.Block.ID() {
return
Expand All @@ -67,8 +68,7 @@ func (r *RequestHandler) SubmitBlockAndAwaitEvent(ctx context.Context, block *mo
}
}, event.WithWorkerPool(r.workerPool)).Unhook

defer lo.Batch(evtUnhook, prefilteredUnhook)()
defer lo.Batch(evtUnhook, postfilteredUnhook)()
defer lo.BatchReverse(evtUnhook, prefilteredUnhook, postfilteredUnhook)()

if err := r.submitBlock(block); err != nil {
return ierrors.Wrapf(err, "failed to issue block %s", blockID)
Expand Down
2 changes: 2 additions & 0 deletions pkg/retainer/blockretainer/block_retainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ func NewProvider() module.Provider[*engine.Engine, retainer.BlockRetainer] {
}
})

e.Events.Retainer.BlockRetained.LinkTo(r.events.BlockRetained)

r.TriggerInitialized()

return r
Expand Down

0 comments on commit 8aa624f

Please sign in to comment.