Skip to content

Commit

Permalink
Merge pull request #4 from leapdao/fix/readonly
Browse files Browse the repository at this point in the history
Fix consensus stalling after readOnly switch
  • Loading branch information
troggy authored Apr 18, 2019
2 parents 1db50cc + 64519e2 commit 30d8df8
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 30d8df8

Please sign in to comment.