From 74a8941854f03bd62bd03a559ec52326c4a26db6 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Fri, 7 Jan 2022 09:15:35 -0500 Subject: [PATCH] consensus: remove reactor options (#7526) --- internal/consensus/reactor.go | 15 ++------------- internal/consensus/reactor_test.go | 1 + node/setup.go | 2 +- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/internal/consensus/reactor.go b/internal/consensus/reactor.go index e7ec24159..25a63d78b 100644 --- a/internal/consensus/reactor.go +++ b/internal/consensus/reactor.go @@ -82,8 +82,6 @@ const ( listenerIDConsensus = "consensus-reactor" ) -type ReactorOption func(*Reactor) - // NOTE: Temporary interface for switching to block sync, we should get rid of v0. // See: https://github.com/tendermint/tendermint/issues/4595 type BlockSyncReactor interface { @@ -141,7 +139,7 @@ func NewReactor( voteSetBitsCh *p2p.Channel, peerUpdates *p2p.PeerUpdates, waitSync bool, - options ...ReactorOption, + metrics *Metrics, ) *Reactor { r := &Reactor{ @@ -149,7 +147,7 @@ func NewReactor( state: cs, waitSync: waitSync, peers: make(map[types.NodeID]*PeerState), - Metrics: NopMetrics(), + Metrics: metrics, stateCh: stateCh, dataCh: dataCh, voteCh: voteCh, @@ -158,10 +156,6 @@ func NewReactor( } r.BaseService = *service.NewBaseService(logger, "Consensus", r) - for _, opt := range options { - opt(r) - } - return r } @@ -236,11 +230,6 @@ func (r *Reactor) WaitSync() bool { return r.waitSync } -// ReactorMetrics sets the reactor's metrics as an option function. -func ReactorMetrics(metrics *Metrics) ReactorOption { - return func(r *Reactor) { r.Metrics = metrics } -} - // SwitchToConsensus switches from block-sync mode to consensus mode. It resets // the state, turns off block-sync, and starts the consensus state-machine. func (r *Reactor) SwitchToConsensus(ctx context.Context, state sm.State, skipWAL bool) { diff --git a/internal/consensus/reactor_test.go b/internal/consensus/reactor_test.go index ac34ab172..5a9eda31c 100644 --- a/internal/consensus/reactor_test.go +++ b/internal/consensus/reactor_test.go @@ -96,6 +96,7 @@ func setup( rts.voteSetBitsChannels[nodeID], node.MakePeerUpdates(ctx, t), true, + NopMetrics(), ) reactor.SetEventBus(state.eventBus) diff --git a/node/setup.go b/node/setup.go index 6408b9456..0d257440e 100644 --- a/node/setup.go +++ b/node/setup.go @@ -334,7 +334,7 @@ func createConsensusReactor( channels[consensus.VoteSetBitsChannel], peerManager.Subscribe(ctx), waitSync, - consensus.ReactorMetrics(csMetrics), + csMetrics, ) // Services which will be publishing and/or subscribing for messages (events)