Browse Source

Merge pull request #677 from hermeznetwork/feature/fastsync-get-headerByNumber

Faster synchronization by fetching only block headers
feature/txsel-l1frozenqueue-acccreation
Eduard S 3 years ago
committed by GitHub
parent
commit
3f643f022a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      eth/ethereum.go

+ 5
- 5
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
}

Loading…
Cancel
Save