From 32341f88e30f55e722f9d335938c4d1ab099f892 Mon Sep 17 00:00:00 2001 From: Hanjiang Yu Date: Tue, 13 Oct 2020 16:55:57 +0800 Subject: [PATCH] console: fix admin.sleepBlocks (#21629) --- console/bridge.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/console/bridge.go b/console/bridge.go index 9303496b2..1a2326919 100644 --- a/console/bridge.go +++ b/console/bridge.go @@ -353,14 +353,14 @@ func (b *bridge) SleepBlocks(call jsre.Call) (goja.Value, error) { } // Poll the current block number until either it or a timeout is reached. - var ( - deadline = time.Now().Add(time.Duration(sleep) * time.Second) - lastNumber = ^hexutil.Uint64(0) - ) + deadline := time.Now().Add(time.Duration(sleep) * time.Second) + var lastNumber hexutil.Uint64 + if err := b.client.Call(&lastNumber, "eth_blockNumber"); err != nil { + return nil, err + } for time.Now().Before(deadline) { var number hexutil.Uint64 - err := b.client.Call(&number, "eth_blockNumber") - if err != nil { + if err := b.client.Call(&number, "eth_blockNumber"); err != nil { return nil, err } if number != lastNumber {