quorum
quorum copied to clipboard
I try to change the conditions to tally.Votes < snap.ValSet.Size()/3 or tally.Votes < 0,but it do not work well
if tally := snap.Tally[candidate]; tally.Votes < snap.ValSet.Size()/2 {
if tally.Authorize {
logger.Info("BFT: reached majority to add validator")
snap.ValSet.AddValidator(candidate)
} else {
logger.Info("BFT: reached majority to remove validator")
snap.ValSet.RemoveValidator(candidate)
// Discard any previous votes the deauthorized validator cast
for i := 0; i < len(snap.Votes); i++ {
if snap.Votes[i].Validator == candidate {
// Uncast the vote from the cached tally
snap.uncast(snap.Votes[i].Address, snap.Votes[i].Authorize)
// Uncast the vote from the chronological list
snap.Votes = append(snap.Votes[:i], snap.Votes[i+1:]...)
i--
}
}
}
// Discard any previous votes around the just changed account
for i := 0; i < len(snap.Votes); i++ {
if snap.Votes[i].Address == candidate {
snap.Votes = append(snap.Votes[:i], snap.Votes[i+1:]...)
i--
}
}
delete(snap.Tally, candidate)
}