EVM-C: Change get_code() to copy_code()

This commit is contained in:
Paweł Bylica 2018-03-26 15:03:19 +02:00
parent 31836e1701
commit ccc3106233
2 changed files with 23 additions and 17 deletions

View File

@ -74,11 +74,10 @@ static size_t get_code_size(struct evm_context* context, const struct evm_addres
return 0; return 0;
} }
static size_t get_code(const uint8_t** code, static size_t copy_code(struct evm_context* context, const struct evm_address* address,
struct evm_context* context, size_t code_offset, uint8_t* buffer_data, size_t buffer_size)
const struct evm_address* address)
{ {
printf("EVM-C: CODE @"); printf("EVM-C: COPYCODE @");
print_address(address); print_address(address);
printf("\n"); printf("\n");
return 0; return 0;
@ -130,7 +129,7 @@ static const struct evm_context_fn_table ctx_fn_table = {
set_storage, set_storage,
get_balance, get_balance,
get_code_size, get_code_size,
get_code, copy_code,
selfdestruct, selfdestruct,
call, call,
get_tx_context, get_tx_context,

View File

@ -351,20 +351,27 @@ typedef void (*evm_get_balance_fn)(struct evm_uint256be* result,
typedef size_t (*evm_get_code_size_fn)(struct evm_context* context, typedef size_t (*evm_get_code_size_fn)(struct evm_context* context,
const struct evm_address* address); const struct evm_address* address);
/// Get code callback function. /// Copy code callback function.
/// ///
/// This callback function is used by an EVM to get the code of a contract of /// This callback function is used by an EVM to request a copy of the code
/// given address. /// of the given account to the memory buffer provided by the EVM.
/// The Client MUST copy the requested code, starting with the given offset,
/// to the provided memory buffer up to the size of the buffer or the size of
/// the code, whichever is smaller.
/// ///
/// @param[out] result_code The pointer to the contract code. /// @param context The pointer to the Client execution context.
/// It will be freed by the Client.
/// @param context The pointer to the Host execution context.
/// @see ::evm_context. /// @see ::evm_context.
/// @param address The address of the contract. /// @param address The address of the account.
/// @return The size of the code. /// @param code_offset The offset of the code to copy.
typedef size_t (*evm_get_code_fn)(const uint8_t** result_code, /// @param buffer_data The pointer to the memory buffer allocated by the EVM
struct evm_context* context, /// to store a copy of the requested code.
const struct evm_address* address); /// @param buffer_size The size of the memory buffer.
/// @return The number of bytes copied to the buffer by the Client.
typedef size_t (*evm_copy_code_fn)(struct evm_context* context,
const struct evm_address* address,
size_t code_offset,
uint8_t* buffer_data,
size_t buffer_size);
/// Selfdestruct callback function. /// Selfdestruct callback function.
/// ///
@ -423,7 +430,7 @@ struct evm_context_fn_table {
evm_set_storage_fn set_storage; evm_set_storage_fn set_storage;
evm_get_balance_fn get_balance; evm_get_balance_fn get_balance;
evm_get_code_size_fn get_code_size; evm_get_code_size_fn get_code_size;
evm_get_code_fn get_code; evm_copy_code_fn copy_code;
evm_selfdestruct_fn selfdestruct; evm_selfdestruct_fn selfdestruct;
evm_call_fn call; evm_call_fn call;
evm_get_tx_context_fn get_tx_context; evm_get_tx_context_fn get_tx_context;