Skip to content

Commit

Permalink
refactor(manager): remove unnecessary start event listener (#712)
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt authored Apr 18, 2024
1 parent ab41f13 commit c9d6171
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ func (m *Manager) Start(ctx context.Context, isAggregator bool) error {
return err
}

m.StartEventListener(ctx, isAggregator)

if isAggregator {
go uevent.MustSubscribe(ctx, m.pubsub, "nodeHealth", events.QueryHealthStatus, m.onNodeHealthStatus, m.logger)
go m.ProduceBlockLoop(ctx)
go m.SubmitLoop(ctx)
} else {
go uevent.MustSubscribe(ctx, m.pubsub, "applyBlockLoop", p2p.EventQueryNewNewGossipedBlock, m.onNewGossipedBlock, m.logger, 100)
go m.RetrieveLoop(ctx)
go m.SyncTargetLoop(ctx)
}
Expand Down Expand Up @@ -211,15 +211,6 @@ func getAddress(key crypto.PrivKey) ([]byte, error) {
return tmcrypto.AddressHash(rawKey), nil
}

// StartEventListener registers events to callbacks.
func (m *Manager) StartEventListener(ctx context.Context, isAggregator bool) {
if isAggregator {
go uevent.MustSubscribe(ctx, m.pubsub, "nodeHealth", events.QueryHealthStatus, m.onNodeHealthStatus, m.logger)
} else {
go uevent.MustSubscribe(ctx, m.pubsub, "applyBlockLoop", p2p.EventQueryNewNewGossipedBlock, m.onNewGossipedBlock, m.logger, 100)
}
}

func (m *Manager) onNodeHealthStatus(event pubsub.Message) {
eventData := event.Data().(*events.DataHealthStatus)
m.logger.Info("received health status event", "eventData", eventData)
Expand Down

0 comments on commit c9d6171

Please sign in to comment.