mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
allow for nil block number to get most recent block
This commit is contained in:
parent
e6f04b6feb
commit
2e8ecf3dc0
1 changed files with 3 additions and 0 deletions
|
|
@ -188,6 +188,9 @@ func (b *SimulatedBackend) TransactionByHash(ctx context.Context, txHash common.
|
|||
// BlockByNumber retrieves a block from the database by number, caching it
|
||||
// (associated with its hash) if found.
|
||||
func (b *SimulatedBackend) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error) {
|
||||
if number == nil {
|
||||
return b.blockchain.CurrentBlock(), nil
|
||||
}
|
||||
block := b.blockchain.GetBlockByNumber(number.Uint64())
|
||||
if block == nil {
|
||||
return nil, errBlockDoesNotExist
|
||||
|
|
|
|||
Loading…
Reference in a new issue