Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit a92c959

Browse files
committed
Move ConstructedEvent triggers
1 parent 9aa9908 commit a92c959

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

pkg/protocol/engine/consensus/slotgadget/totalweightslotgadget/gadget.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ func NewProvider(opts ...options.Option[Gadget]) module.Provider[*engine.Engine,
4242
e.ConstructedEvent().OnTrigger(func() {
4343
g.seatManager = e.SybilProtection.SeatManager()
4444

45-
e.Events.BlockGadget.BlockConfirmed.Hook(g.trackVotes)
46-
4745
g.storeLastFinalizedSlotFunc = func(slot iotago.SlotIndex) {
4846
if err := e.Storage.Settings().SetLatestFinalizedSlot(slot); err != nil {
4947
g.errorHandler(ierrors.Wrap(err, "failed to set latest finalized slot"))
5048
}
5149
}
5250

51+
g.ConstructedEvent().Trigger()
52+
53+
e.Events.BlockGadget.BlockConfirmed.Hook(g.trackVotes)
54+
5355
e.InitializedEvent().OnTrigger(func() {
5456
// Can't use setter here as it has a side effect.
5557
g.mutex.Lock()
@@ -79,8 +81,6 @@ func New(subModule module.Module, engine *engine.Engine, opts ...options.Option[
7981
g.ShutdownEvent().OnTrigger(func() {
8082
g.StoppedEvent().Trigger()
8183
})
82-
83-
g.ConstructedEvent().Trigger()
8484
})
8585
}
8686

pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ func NewProvider(opts ...options.Option[SybilProtection]) module.Provider[*engin
6363
}
6464
}
6565

66+
s.ConstructedEvent().Trigger()
67+
6668
// When the engine is triggered initialized, snapshot has been read or database has been initialized properly,
6769
// so the committee should be available in the performance manager.
6870
e.InitializedEvent().OnTrigger(func() {
@@ -99,8 +101,6 @@ func New(subModule module.Module, engine *engine.Engine, opts ...options.Option[
99101
s.ShutdownEvent().OnTrigger(func() {
100102
s.StoppedEvent().Trigger()
101103
})
102-
103-
s.ConstructedEvent().Trigger()
104104
})
105105
}
106106

0 commit comments

Comments
 (0)