Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Reduce rows for shorter windows. Decimals for prevote/commit. #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func main() {
if propIdx >= 0 {
proposer = v.GetInfo(propIdx)
}
SummaryChan <- fmt.Sprintf("height/round/step: %s - v: %.0f%% c: %.0f%% (%v)\n\nProposer:\n(rank/%%/moniker) %s", hrs, votePct*100, commitPct*100, dur, proposer)
SummaryChan <- fmt.Sprintf("height/round/step: %s - v: %.2f%% c: %.2f%% (%v)\n\nProposer:\n(rank/%%/moniker) %s", hrs, votePct*100, commitPct*100, dur, proposer)
voteChan <- votes
votePctChan <- votePct
commitPctChan <- commitPct
Expand Down
25 changes: 17 additions & 8 deletions prevotes/term.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,30 @@ func DrawScreen(network string, voteChan chan []VoteState, votePctChan, commitPc

func splitVotes(votes []VoteState) ([][]VoteState, int) {
split := make([][]VoteState, 0)
_, termHeight := ui.TerminalDimensions()
visibleRows := termHeight - 10

var max int
switch {
case len(votes) < 50:
case visibleRows >= len(votes):
max = 1
split = append(split, votes)
case len(votes) < 100:
case visibleRows * 2 >= len(votes):
max = 2
split = append(split, votes[:50])
split = append(split, votes[50:])
if visibleRows >= 50 {
split = append(split, votes[:50])
split = append(split, votes[50:])
} else {
rowsPerColumn := (len(votes) + max - 1)/2
split = append(split, votes[:rowsPerColumn])
split = append(split, votes[rowsPerColumn:])
}
default:
max = 3
rows := (len(votes) + max - 1)/3
split = append(split, votes[:rows])
split = append(split, votes[rows:rows*2])
split = append(split, votes[rows*2:])
rowsPerColumn := (len(votes) + max - 1)/3
split = append(split, votes[:rowsPerColumn])
split = append(split, votes[rowsPerColumn:rowsPerColumn*2])
split = append(split, votes[rowsPerColumn*2:])
}
return split, max
}