From 2e8ecf3dc07cb9786a9094f92efc680e9ddf4e9b Mon Sep 17 00:00:00 2001 From: Ilan Gitter Date: Thu, 4 Oct 2018 17:38:30 -0400 Subject: [PATCH] allow for nil block number to get most recent block --- accounts/abi/bind/backends/simulated.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 7d11170e48..76c6aa9ea9 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -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