consensus: lock before loading commit
This commit is contained in:
parent
904eeddf36
commit
c6a648fad7
|
@ -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(),
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue