Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve long time consensus stuck by network and simple refactorings #915

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/consensus/ballot_send_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ func NewBallotSendRecord(nodeAlias string) *BallotSendRecord {
return p
}

// SetSent sets that the ballot of this ISAACState has already been sent.
// This is to prevent one node from retransmitting another result.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big big 👍 for documenting what the function is for. It's much more important than what the function do (which one can understand from the code).

func (r *BallotSendRecord) SetSent(state ISAACState) {
r.Lock()
defer r.Unlock()
Expand All @@ -33,6 +35,17 @@ func (r *BallotSendRecord) SetSent(state ISAACState) {
return
}

// InitSent initializes the ballot transfer record of this ISAACState.InitSent.
// This function is used when an existing ballot has expired.
func (r *BallotSendRecord) InitSent(state ISAACState) {
r.Lock()
defer r.Unlock()
log.Debug("BallotSendRecord.InitSent()", "state", state)
r.record[state] = false

return
}

func (r *BallotSendRecord) Sent(state ISAACState) bool {
r.RLock()
defer r.RUnlock()
Expand Down
4 changes: 4 additions & 0 deletions lib/node/runner/node_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,3 +770,7 @@ func (nr *NodeRunner) BroadcastBallot(b ballot.Ballot) {

nr.ConnectionManager().Broadcast(b)
}

func (nr *NodeRunner) InitSent(state consensus.ISAACState) {
nr.ballotSendRecord.InitSent(state)
}