From 0223582d4106e36d212827fb2f5aa9f4c9189b34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 8 Oct 2020 22:48:21 +0200 Subject: [PATCH] sync wait: Handle processed message offset --- cli/sync.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cli/sync.go b/cli/sync.go index bee87cf70..dea96d14e 100644 --- a/cli/sync.go +++ b/cli/sync.go @@ -233,7 +233,13 @@ func SyncWait(ctx context.Context, napi api.FullNode) error { samples := 8 i := 0 - var app, lastApp uint64 + var firstApp, app, lastApp uint64 + + state, err := napi.SyncState(ctx) + if err != nil { + return err + } + firstApp = state.VMApplied for { state, err := napi.SyncState(ctx) @@ -286,10 +292,10 @@ func SyncWait(ctx context.Context, napi api.FullNode) error { if i%samples == 0 { lastApp = app - app = state.VMApplied + app = state.VMApplied - firstApp } if i > 0 { - fmt.Printf("Validated %d messages (%d per second)\n", state.VMApplied, (app-lastApp)*uint64(time.Second/tick)/uint64(samples)) + fmt.Printf("Validated %d messages (%d per second)\n", state.VMApplied-firstApp, (app-lastApp)*uint64(time.Second/tick)/uint64(samples)) lastLines++ }