From 8a0aaaf498e0a20e41852accd942cac5a1a55295 Mon Sep 17 00:00:00 2001 From: Chill Validation <92176880+chillyvee@users.noreply.github.com> Date: Wed, 17 May 2023 16:09:35 +1000 Subject: [PATCH 1/2] Auto reduce rows for shorter windows. Show decimals for prevote/commit. --- main.go | 2 +- prevotes/term.go | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 0cf39b7..1574f3b 100644 --- a/main.go +++ b/main.go @@ -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 diff --git a/prevotes/term.go b/prevotes/term.go index 7dc7ea7..0239f60 100644 --- a/prevotes/term.go +++ b/prevotes/term.go @@ -109,15 +109,24 @@ func DrawScreen(network string, voteChan chan []VoteState, votePctChan, commitPc func splitVotes(votes []VoteState) ([][]VoteState, int) { split := make([][]VoteState, 0) + _, termHeight := ui.TerminalDimensions() + validatorRows := termHeight - 10 + var max int switch { - case len(votes) < 50: + case validatorRows >= len(votes): max = 1 split = append(split, votes) - case len(votes) < 100: + case validatorRows * 2 >= len(votes): max = 2 - split = append(split, votes[:50]) - split = append(split, votes[50:]) + if validatorRows >= 50 { + split = append(split, votes[:50]) + split = append(split, votes[50:]) + } else { + rows := (len(votes) + max - 1)/2 + split = append(split, votes[:rows]) + split = append(split, votes[rows:]) + } default: max = 3 rows := (len(votes) + max - 1)/3 From 4ab9419148daf4172c09b8f3c9f3428a294f85ca Mon Sep 17 00:00:00 2001 From: Chill Validation <92176880+chillyvee@users.noreply.github.com> Date: Wed, 17 May 2023 16:13:06 +1000 Subject: [PATCH 2/2] slightly better variable names --- prevotes/term.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/prevotes/term.go b/prevotes/term.go index 0239f60..372c20c 100644 --- a/prevotes/term.go +++ b/prevotes/term.go @@ -110,29 +110,29 @@ func DrawScreen(network string, voteChan chan []VoteState, votePctChan, commitPc func splitVotes(votes []VoteState) ([][]VoteState, int) { split := make([][]VoteState, 0) _, termHeight := ui.TerminalDimensions() - validatorRows := termHeight - 10 + visibleRows := termHeight - 10 var max int switch { - case validatorRows >= len(votes): + case visibleRows >= len(votes): max = 1 split = append(split, votes) - case validatorRows * 2 >= len(votes): + case visibleRows * 2 >= len(votes): max = 2 - if validatorRows >= 50 { + if visibleRows >= 50 { split = append(split, votes[:50]) split = append(split, votes[50:]) } else { - rows := (len(votes) + max - 1)/2 - split = append(split, votes[:rows]) - split = append(split, votes[rows:]) + 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 }