consensus: lock before loading commit

This commit is contained in:
Ethan Buchman
2016-11-16 16:47:31 -05:00
parent 904eeddf36
commit c6a648fad7
2 changed files with 10 additions and 6 deletions

View File

@ -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()