M election/msg.go => election/msg.go +5 -7
@@ 503,17 503,15 @@ func (elections *ElectionsMap) onSumMessage(evt *event.Event) (success bool) {
voter.SumID = &evt.ID
voter.Sum = new(big.Int).SetBytes(bytes)
- // once we've recieved all sums, calculate the election result!
- receivedAllSums := true
+ // if we've recieved all sums, calculate the election result!
for _, voterID := range *el.FinalJoinIDs {
if el.Joins[voterID].SumID == nil {
- receivedAllSums = false
- break
+ // still need at least one voter's sum, but this event
+ // was processed successfully
+ return true
}
}
- if receivedAllSums {
- el.CalculateResult()
- }
+ el.calculateResult()
return true
}
M election/result.go => election/result.go +1 -1
@@ 10,7 10,7 @@ import (
"tallyard.xyz/math"
)
-func (el *Election) CalculateResult() {
+func (el *Election) calculateResult() {
// this assumes all sums have been received and successfully validated
// and processed
M := constructPolyMatrix(el)