From 9999e48bdc7906a00d66bc8f3e6273bd83ac522f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Thu, 16 Feb 2023 13:48:52 +0100 Subject: [PATCH] fix: `polycli monitor` block order (#40) * chore: remove dead code * fix: compare block numbers if timestamps are equal * refactor: compare blocks only by their blockNumber property --- cmd/monitor/monitor.go | 5 ----- metrics/metrics.go | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/cmd/monitor/monitor.go b/cmd/monitor/monitor.go index 3306e2c8..70d70005 100644 --- a/cmd/monitor/monitor.go +++ b/cmd/monitor/monitor.go @@ -140,11 +140,6 @@ var MonitorCmd = &cobra.Command{ from := big.NewInt(0) - // batchSize := *inputBatchSize - // if *inputBatchSize > 0 { - // batchSize = *inputBatchSize - // } - // if the max block is 0, meaning we haven't fetched any blocks, we're going to start with head - batchSize if ms.MaxBlockRetrieved.Cmp(from) == 0 { headBlockMinusBatchSize := new(big.Int).SetUint64(*inputBatchSize + 100 - 1) diff --git a/metrics/metrics.go b/metrics/metrics.go index 72ad8e94..00e56b10 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -40,7 +40,7 @@ func (a SortableBlocks) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a SortableBlocks) Less(i, j int) bool { - return a[i].Time() < a[j].Time() + return a[i].Number().Int64() < a[j].Number().Int64() } func GetMeanBlockTime(blocks []rpctypes.PolyBlock) float64 {