summaryrefslogtreecommitdiff
path: root/internal/quorum/quorum.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/quorum/quorum.go')
-rw-r--r--internal/quorum/quorum.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/internal/quorum/quorum.go b/internal/quorum/quorum.go
index 37b351c..25852b2 100644
--- a/internal/quorum/quorum.go
+++ b/internal/quorum/quorum.go
@@ -92,7 +92,8 @@ func (quo Quorum) scores() (scores []Score) {
}
for _, id := range vote.IDs {
score := scoreMap[id]
- scoreMap[id] = score + 100
+ nodeNumber := quo.conf.NodeNumber(id)
+ scoreMap[id] = score + 100 + (len(quo.conf.Nodes) - nodeNumber)
}
}
@@ -101,14 +102,7 @@ func (quo Quorum) scores() (scores []Score) {
}
sort.Slice(scores, func(i, j int) bool {
- if scores[i].Value != scores[j].Value {
- return scores[i].Value > scores[j].Value
- }
-
- // Score tie, use node number.
- i_, _ := quo.conf.NodeNumber(scores[i].ID)
- j_, _ := quo.conf.NodeNumber(scores[j].ID)
- return i_ < j_
+ return scores[i].Value > scores[j].Value
})
return
@@ -145,7 +139,10 @@ func (quo *Quorum) persistScores() error {
}
sb.WriteString(score.ID)
- sb.WriteString(" with score of ")
+ sb.WriteString(" (node #")
+ sb.WriteString(strconv.Itoa(quo.conf.NodeNumber(score.ID)))
+
+ sb.WriteString(") with total score of ")
sb.WriteString(strconv.Itoa(score.Value))
sb.WriteString("\n")