diff --git a/consensus/reactor.go b/consensus/reactor.go index 0ece82ce1..60d5a8f5d 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -658,12 +658,7 @@ OUTER_LOOP: { prs := ps.GetRoundState() if prs.CatchupCommitRound != -1 && 0 < prs.Height && prs.Height <= conR.conS.blockStore.Height() { - var commit *types.Commit - if prs.Height == conR.conS.blockStore.Height() { - commit = conR.conS.blockStore.LoadSeenCommit(prs.Height) - } else { - commit = conR.conS.blockStore.LoadBlockCommit(prs.Height) - } + commit := conR.conS.LoadCommit(prs.Height) peer.TrySend(StateChannel, struct{ ConsensusMessage }{&VoteSetMaj23Message{ Height: prs.Height, Round: commit.Round(), diff --git a/consensus/state.go b/consensus/state.go index 59bea2315..85d4d1679 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -319,6 +319,15 @@ func (cs *ConsensusState) SetPrivValidator(priv PrivValidator) { cs.privValidator = priv } +func (cs *ConsensusState) LoadCommit(height int) *types.Commit { + cs.mtx.Lock() + defer cs.mtx.Unlock() + if height == cs.blockStore.Height() { + return cs.blockStore.LoadSeenCommit(height) + } + return cs.blockStore.LoadBlockCommit(height) +} + func (cs *ConsensusState) OnStart() error { cs.BaseService.OnStart()