sync wait: Handle processed message offset

This commit is contained in:
Łukasz Magiera 2020-10-08 22:48:21 +02:00
parent e4d2e6e01d
commit 0223582d41

View File

@ -233,7 +233,13 @@ func SyncWait(ctx context.Context, napi api.FullNode) error {
samples := 8 samples := 8
i := 0 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 { for {
state, err := napi.SyncState(ctx) state, err := napi.SyncState(ctx)
@ -286,10 +292,10 @@ func SyncWait(ctx context.Context, napi api.FullNode) error {
if i%samples == 0 { if i%samples == 0 {
lastApp = app lastApp = app
app = state.VMApplied app = state.VMApplied - firstApp
} }
if i > 0 { 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++ lastLines++
} }