From 2125812e90ab32eb14cc53b21c69043600a751d3 Mon Sep 17 00:00:00 2001 From: Oleksandr Brezhniev Date: Tue, 23 Mar 2021 15:40:11 +0200 Subject: [PATCH] Faster synchronization with usage of HeaderByNumber instead of BlockByNumber --- eth/ethereum.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/eth/ethereum.go b/eth/ethereum.go index fcfba50..de3c99f 100644 --- a/eth/ethereum.go +++ b/eth/ethereum.go @@ -245,15 +245,15 @@ func (c *EthereumClient) EthBlockByNumber(ctx context.Context, number int64) (*c if number == -1 { blockNum = nil } - block, err := c.client.BlockByNumber(ctx, blockNum) + header, err := c.client.HeaderByNumber(ctx, blockNum) if err != nil { return nil, tracerr.Wrap(err) } b := &common.Block{ - Num: block.Number().Int64(), - Timestamp: time.Unix(int64(block.Time()), 0), - ParentHash: block.ParentHash(), - Hash: block.Hash(), + Num: header.Number.Int64(), + Timestamp: time.Unix(int64(header.Time), 0), + ParentHash: header.ParentHash, + Hash: header.Hash(), } return b, nil }