Skip to content

Commit

Permalink
Fix consensus stalling after readOnly switch
Browse files Browse the repository at this point in the history
Consensus stalls if there are no other validators in the network and
the validator is switched from readOnly=true back to readOnly=false.

Fixes #3
  • Loading branch information
pinkiebell committed Apr 13, 2019
1 parent 1db50cc commit 64519e2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,17 @@ func (cs *ConsensusState) handleTxsAvailable() {
}

func (cs *ConsensusState) SetReadonly(readonly bool) {
cs.readonly = readonly
cs.Logger.Info("[SetReadonly]: Set to " + strconv.FormatBool(readonly) + " " + strconv.FormatBool(cs.readonly))
cs.mtx.Lock()
cs.readonly = readonly
cs.mtx.Unlock()

if (!cs.readonly) {
if (cs.LastCommit.HasAll()) {
// Fix consensus stalling after readOnly switch with no other validators in the network
cs.scheduleTimeout(5000, cs.Height, cs.Round, cstypes.RoundStepPrevoteWait)
}
}
}

func (cs *ConsensusState) IsReadonly() bool {
Expand Down

0 comments on commit 64519e2

Please sign in to comment.