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;
}
static size_t get_code(const uint8_t** code,
struct evm_context* context,
const struct evm_address* address)
static size_t copy_code(struct evm_context* context, const struct evm_address* address,
size_t code_offset, uint8_t* buffer_data, size_t buffer_size)
{
printf("EVM-C: CODE @");
printf("EVM-C: COPYCODE @");
print_address(address);
printf("\n");
return 0;
@ -130,7 +129,7 @@ static const struct evm_context_fn_table ctx_fn_table = {
set_storage,
get_balance,
get_code_size,
get_code,
copy_code,
selfdestruct,
call,
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,
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
/// given address.
/// This callback function is used by an EVM to request a copy of the code
/// 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.
/// It will be freed by the Client.
/// @param context The pointer to the Host execution context.
/// @param context The pointer to the Client execution context.
/// @see ::evm_context.
/// @param address The address of the contract.
/// @return The size of the code.
typedef size_t (*evm_get_code_fn)(const uint8_t** result_code,
struct evm_context* context,
const struct evm_address* address);
/// @param address The address of the account.
/// @param code_offset The offset of the code to copy.
/// @param buffer_data The pointer to the memory buffer allocated by the EVM
/// to store a copy of the requested code.
/// @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.
///
@ -423,7 +430,7 @@ struct evm_context_fn_table {
evm_set_storage_fn set_storage;
evm_get_balance_fn get_balance;
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_call_fn call;
evm_get_tx_context_fn get_tx_context;