go: Add error output to Host.GetBlockHash()

This commit is contained in:
Paweł Bylica 2018-09-03 16:49:01 +02:00
parent d9f7ff25f5
commit d0bc50792a
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
1 changed files with 3 additions and 6 deletions

View File

@ -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)
}