From d0bc50792ac624999189f7bd7657083d7833a993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 3 Sep 2018 16:49:01 +0200 Subject: [PATCH] go: Add error output to Host.GetBlockHash() --- bindings/go/evmc/host.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/bindings/go/evmc/host.go b/bindings/go/evmc/host.go index 0f740f5..d9f787f 100644 --- a/bindings/go/evmc/host.go +++ b/bindings/go/evmc/host.go @@ -79,7 +79,7 @@ type HostContext interface { Selfdestruct(addr common.Address, beneficiary common.Address) GetTxContext() (gasPrice common.Hash, origin common.Address, coinbase common.Address, number int64, timestamp int64, gasLimit int64, difficulty common.Hash) - GetBlockHash(number int64) common.Hash + GetBlockHash(number int64) (common.Hash, error) EmitLog(addr common.Address, topics []common.Hash, data []byte) Call(kind CallKind, destination common.Address, sender common.Address, value *big.Int, input []byte, gas int64, depth int, @@ -186,11 +186,8 @@ func getBlockHash(pResult *C.struct_evmc_uint256be, pCtx unsafe.Pointer, number idx := int((*C.struct_extended_context)(pCtx).index) ctx := getHostContext(idx) - blockhash := ctx.GetBlockHash(number) - - // FIXME: should we instead adjust `ctx.GetBlockHash`? - if blockhash == (common.Hash{}) { - // All zeroes hash is considered a failure in lookup. + blockhash, err := ctx.GetBlockHash(number) + if err != nil { return C.int(0) }