Skip to content

Commit

Permalink
Move ConstructedEvent triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
muXxer committed Mar 28, 2024
1 parent 9aa9908 commit a92c959
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ func NewProvider(opts ...options.Option[Gadget]) module.Provider[*engine.Engine,
e.ConstructedEvent().OnTrigger(func() {
g.seatManager = e.SybilProtection.SeatManager()

e.Events.BlockGadget.BlockConfirmed.Hook(g.trackVotes)

g.storeLastFinalizedSlotFunc = func(slot iotago.SlotIndex) {
if err := e.Storage.Settings().SetLatestFinalizedSlot(slot); err != nil {
g.errorHandler(ierrors.Wrap(err, "failed to set latest finalized slot"))
}
}

g.ConstructedEvent().Trigger()

e.Events.BlockGadget.BlockConfirmed.Hook(g.trackVotes)

e.InitializedEvent().OnTrigger(func() {
// Can't use setter here as it has a side effect.
g.mutex.Lock()
Expand Down Expand Up @@ -79,8 +81,6 @@ func New(subModule module.Module, engine *engine.Engine, opts ...options.Option[
g.ShutdownEvent().OnTrigger(func() {
g.StoppedEvent().Trigger()
})

g.ConstructedEvent().Trigger()
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ func NewProvider(opts ...options.Option[SybilProtection]) module.Provider[*engin
}
}

s.ConstructedEvent().Trigger()

// When the engine is triggered initialized, snapshot has been read or database has been initialized properly,
// so the committee should be available in the performance manager.
e.InitializedEvent().OnTrigger(func() {
Expand Down Expand Up @@ -99,8 +101,6 @@ func New(subModule module.Module, engine *engine.Engine, opts ...options.Option[
s.ShutdownEvent().OnTrigger(func() {
s.StoppedEvent().Trigger()
})

s.ConstructedEvent().Trigger()
})
}

Expand Down

0 comments on commit a92c959

Please sign in to comment.