mirror of
https://github.com/status-im/evmc.git
synced 2025-02-22 16:08:22 +00:00
Add return code to get_block_hash_fn
This commit is contained in:
parent
7a3f6bb57a
commit
d9f7ff25f5
@ -97,8 +97,8 @@ static inline void go_exported_functions_type_checks()
|
||||
tx_context = getTxContext(context);
|
||||
|
||||
evmc_get_block_hash_fn get_block_hash_fn = NULL;
|
||||
get_block_hash_fn(uint256be, context, number);
|
||||
getBlockHash(uint256be, context, number);
|
||||
status = get_block_hash_fn(uint256be, context, number);
|
||||
status = getBlockHash(uint256be, context, number);
|
||||
|
||||
evmc_emit_log_fn emit_log_fn = NULL;
|
||||
emit_log_fn(context, address, data, size, uint256be, size);
|
||||
|
@ -182,11 +182,20 @@ func getTxContext(pCtx unsafe.Pointer) C.struct_evmc_tx_context {
|
||||
}
|
||||
|
||||
//export getBlockHash
|
||||
func getBlockHash(pResult *C.struct_evmc_uint256be, pCtx unsafe.Pointer, number int64) {
|
||||
func getBlockHash(pResult *C.struct_evmc_uint256be, pCtx unsafe.Pointer, number int64) C.int {
|
||||
idx := int((*C.struct_extended_context)(pCtx).index)
|
||||
ctx := getHostContext(idx)
|
||||
|
||||
*pResult = evmcUint256be(ctx.GetBlockHash(number))
|
||||
blockhash := ctx.GetBlockHash(number)
|
||||
|
||||
// FIXME: should we instead adjust `ctx.GetBlockHash`?
|
||||
if blockhash == (common.Hash{}) {
|
||||
// All zeroes hash is considered a failure in lookup.
|
||||
return C.int(0)
|
||||
}
|
||||
|
||||
*pResult = evmcUint256be(blockhash)
|
||||
return C.int(1)
|
||||
}
|
||||
|
||||
//export emitLog
|
||||
|
@ -107,11 +107,12 @@ static evmc_tx_context get_tx_context(evmc_context* context)
|
||||
return result;
|
||||
}
|
||||
|
||||
static void get_block_hash(evmc_uint256be* result, evmc_context* context, int64_t number)
|
||||
static int get_block_hash(evmc_uint256be* result, evmc_context* context, int64_t number)
|
||||
{
|
||||
(void)result;
|
||||
(void)context;
|
||||
(void)number;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void emit_log(evmc_context* context,
|
||||
|
@ -153,17 +153,19 @@ typedef struct evmc_tx_context (*evmc_get_tx_context_fn)(struct evmc_context* co
|
||||
/**
|
||||
* Get block hash callback function.
|
||||
*
|
||||
* This callback function is used by an EVM to query the block hash of
|
||||
* a given block.
|
||||
* This callback function is used by an VM to query the block hash of
|
||||
* a given block. If the requested block is not found, then an appropriate
|
||||
* result code is returned.
|
||||
*
|
||||
* @param[out] result The returned block hash value.
|
||||
* @param[out] result The returned block hash value. Only written to
|
||||
* if the return value is 1 (information is avialable).
|
||||
* @param context The pointer to the Host execution context.
|
||||
* @param number The block number. Must be a value between
|
||||
* (and including) 0 and 255.
|
||||
* @param number The block number.
|
||||
* @return 1 if the information is available, 0 otherwise.
|
||||
*/
|
||||
typedef void (*evmc_get_block_hash_fn)(struct evmc_uint256be* result,
|
||||
struct evmc_context* context,
|
||||
int64_t number);
|
||||
typedef int (*evmc_get_block_hash_fn)(struct evmc_uint256be* result,
|
||||
struct evmc_context* context,
|
||||
int64_t number);
|
||||
|
||||
/**
|
||||
* The execution status code.
|
||||
|
Loading…
x
Reference in New Issue
Block a user