Skip to content

Commit

Permalink
Merge pull request #2908 from oasislabs/pro-wh/feature/rank
Browse files Browse the repository at this point in the history
go stats: give ties the same rank
  • Loading branch information
pro-wh committed May 29, 2020
1 parent 08a6429 commit bfce631
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .changelog/2908.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
go/extra/stats: Give ties the same rank

Previously records tied by availability score would get different
ranks, which was wrong.
8 changes: 7 additions & 1 deletion go/extra/stats/cmd/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,14 @@ func (s stats) printEntityAvailability(topN int) {
// Print results.
written, _ := fmt.Printf("|%-5s|%-64s|%-6s|%13s|%10s|%14s|%9s|%18s|\n", "Rank", "Entity ID", "Nodes", "Had validator", "Signatures", "Times selected", "Proposals", "Availability score")
fmt.Println(strings.Repeat("-", written-1))
rank := 0
tieScore := int64(0)
for idx, r := range res {
fmt.Printf("|%-5d|%-64s|%6d|%13d|%10d|%14d|%9d|%18d|\n", idx+1, r.entityID, r.nodes, r.elections, r.signatures, r.selections, r.proposals, r.availabilityScore)
if idx == 0 || r.availabilityScore != tieScore {
rank = idx + 1
tieScore = r.availabilityScore
}
fmt.Printf("|%-5d|%-64s|%6d|%13d|%10d|%14d|%9d|%18d|\n", rank, r.entityID, r.nodes, r.elections, r.signatures, r.selections, r.proposals, r.availabilityScore)
}
}

Expand Down

0 comments on commit bfce631

Please sign in to comment.