mirror of https://github.com/status-im/evmc.git
Return bool from evmc_get_code_size_fn()
This commit is contained in:
parent
d6ef551541
commit
b8b3719fb9
|
@ -73,8 +73,8 @@ static inline void go_exported_functions_type_checks()
|
|||
bool_flag = getBalance(uint256be, context, address);
|
||||
|
||||
evmc_get_code_size_fn get_code_size_fn = NULL;
|
||||
size = get_code_size_fn(context, address);
|
||||
size = getCodeSize(context, address);
|
||||
bool_flag = get_code_size_fn(&size, context, address);
|
||||
bool_flag = getCodeSize(&size, context, address);
|
||||
|
||||
evmc_get_code_hash_fn get_code_hash_fn = NULL;
|
||||
bool_flag = get_code_hash_fn(uint256be, context, address);
|
||||
|
|
|
@ -74,7 +74,7 @@ type HostContext interface {
|
|||
GetStorage(addr common.Address, key common.Hash) common.Hash
|
||||
SetStorage(addr common.Address, key common.Hash, value common.Hash) StorageStatus
|
||||
GetBalance(addr common.Address) (common.Hash, error)
|
||||
GetCodeSize(addr common.Address) int
|
||||
GetCodeSize(addr common.Address) (int, error)
|
||||
GetCodeHash(addr common.Address) (common.Hash, error)
|
||||
GetCode(addr common.Address) []byte
|
||||
Selfdestruct(addr common.Address, beneficiary common.Address)
|
||||
|
@ -122,10 +122,15 @@ func getBalance(pResult *C.struct_evmc_uint256be, pCtx unsafe.Pointer, pAddr *C.
|
|||
}
|
||||
|
||||
//export getCodeSize
|
||||
func getCodeSize(pCtx unsafe.Pointer, pAddr *C.struct_evmc_address) C.size_t {
|
||||
func getCodeSize(pResult *C.size_t, pCtx unsafe.Pointer, pAddr *C.struct_evmc_address) C.bool {
|
||||
idx := int((*C.struct_extended_context)(pCtx).index)
|
||||
ctx := getHostContext(idx)
|
||||
return C.size_t(ctx.GetCodeSize(goAddress(*pAddr)))
|
||||
codeSize, err := ctx.GetCodeSize(goAddress(*pAddr))
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
*pResult = C.size_t(codeSize)
|
||||
return true
|
||||
}
|
||||
|
||||
//export getCodeHash
|
||||
|
|
|
@ -60,11 +60,12 @@ static bool get_balance(evmc_uint256be* result, evmc_context* context, const evm
|
|||
return true;
|
||||
}
|
||||
|
||||
static size_t get_code_size(evmc_context* context, const evmc_address* address)
|
||||
static bool get_code_size(size_t* result, evmc_context* context, const evmc_address* address)
|
||||
{
|
||||
(void)result;
|
||||
(void)context;
|
||||
(void)address;
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool get_code_hash(evmc_uint256be* result,
|
||||
|
|
|
@ -494,11 +494,21 @@ typedef bool (*evmc_get_balance_fn)(struct evmc_uint256be* result,
|
|||
/**
|
||||
* Get code size callback function.
|
||||
*
|
||||
* This callback function is used by an EVM to get the size of the code stored
|
||||
* in the account at the given address. For accounts not having a code, this
|
||||
* function returns 0.
|
||||
* This callback function is used by a VM to get the size of the code stored
|
||||
* in the account at the given address.
|
||||
*
|
||||
* @param[out] result The pointer to the place where to put the result code size.
|
||||
* The pointed memory is only modified when the function returns true.
|
||||
* The pointer MUST NOT be null.
|
||||
* @param context The pointer to the Host execution context.
|
||||
* @param address The address of the account.
|
||||
* @return If the account exists the size of its code is put at the location
|
||||
* pointed by @p result and true is returned.
|
||||
* If the account does not exist false is returned without
|
||||
* modifying the memory pointed by @p result.
|
||||
*/
|
||||
typedef size_t (*evmc_get_code_size_fn)(struct evmc_context* context,
|
||||
typedef bool (*evmc_get_code_size_fn)(size_t* result,
|
||||
struct evmc_context* context,
|
||||
const struct evmc_address* address);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue