|
@ -82,8 +82,6 @@ const ( |
|
|
listenerIDConsensus = "consensus-reactor" |
|
|
listenerIDConsensus = "consensus-reactor" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
type ReactorOption func(*Reactor) |
|
|
|
|
|
|
|
|
|
|
|
// NOTE: Temporary interface for switching to block sync, we should get rid of v0.
|
|
|
// NOTE: Temporary interface for switching to block sync, we should get rid of v0.
|
|
|
// See: https://github.com/tendermint/tendermint/issues/4595
|
|
|
// See: https://github.com/tendermint/tendermint/issues/4595
|
|
|
type BlockSyncReactor interface { |
|
|
type BlockSyncReactor interface { |
|
@ -141,7 +139,7 @@ func NewReactor( |
|
|
voteSetBitsCh *p2p.Channel, |
|
|
voteSetBitsCh *p2p.Channel, |
|
|
peerUpdates *p2p.PeerUpdates, |
|
|
peerUpdates *p2p.PeerUpdates, |
|
|
waitSync bool, |
|
|
waitSync bool, |
|
|
options ...ReactorOption, |
|
|
|
|
|
|
|
|
metrics *Metrics, |
|
|
) *Reactor { |
|
|
) *Reactor { |
|
|
|
|
|
|
|
|
r := &Reactor{ |
|
|
r := &Reactor{ |
|
@ -149,7 +147,7 @@ func NewReactor( |
|
|
state: cs, |
|
|
state: cs, |
|
|
waitSync: waitSync, |
|
|
waitSync: waitSync, |
|
|
peers: make(map[types.NodeID]*PeerState), |
|
|
peers: make(map[types.NodeID]*PeerState), |
|
|
Metrics: NopMetrics(), |
|
|
|
|
|
|
|
|
Metrics: metrics, |
|
|
stateCh: stateCh, |
|
|
stateCh: stateCh, |
|
|
dataCh: dataCh, |
|
|
dataCh: dataCh, |
|
|
voteCh: voteCh, |
|
|
voteCh: voteCh, |
|
@ -158,10 +156,6 @@ func NewReactor( |
|
|
} |
|
|
} |
|
|
r.BaseService = *service.NewBaseService(logger, "Consensus", r) |
|
|
r.BaseService = *service.NewBaseService(logger, "Consensus", r) |
|
|
|
|
|
|
|
|
for _, opt := range options { |
|
|
|
|
|
opt(r) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return r |
|
|
return r |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -236,11 +230,6 @@ func (r *Reactor) WaitSync() bool { |
|
|
return r.waitSync |
|
|
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
|
|
|
// SwitchToConsensus switches from block-sync mode to consensus mode. It resets
|
|
|
// the state, turns off block-sync, and starts the consensus state-machine.
|
|
|
// the state, turns off block-sync, and starts the consensus state-machine.
|
|
|
func (r *Reactor) SwitchToConsensus(ctx context.Context, state sm.State, skipWAL bool) { |
|
|
func (r *Reactor) SwitchToConsensus(ctx context.Context, state sm.State, skipWAL bool) { |
|
|