mirror of https://github.com/status-im/evmc.git
Merge pull request #114 from ethereum/tx-context
Return evmc_tx_context in get_tx_context (as opposed to pointer parameter)
This commit is contained in:
commit
4955ebfba1
|
@ -46,8 +46,9 @@ static inline void go_exported_functions_type_checks()
|
|||
size_t size = 0;
|
||||
int64_t number = 0;
|
||||
struct evmc_message* message = NULL;
|
||||
struct evmc_tx_context* tx_context = NULL;
|
||||
|
||||
struct evmc_tx_context tx_context;
|
||||
(void)tx_context;
|
||||
struct evmc_result result;
|
||||
(void)result;
|
||||
enum evmc_storage_status storage_status;
|
||||
|
@ -92,8 +93,8 @@ static inline void go_exported_functions_type_checks()
|
|||
result = call(context, message);
|
||||
|
||||
evmc_get_tx_context_fn get_tx_context_fn = NULL;
|
||||
get_tx_context_fn(tx_context, context);
|
||||
getTxContext(tx_context, context);
|
||||
tx_context = get_tx_context_fn(context);
|
||||
tx_context = getTxContext(context);
|
||||
|
||||
evmc_get_block_hash_fn get_block_hash_fn = NULL;
|
||||
get_block_hash_fn(uint256be, context, number);
|
||||
|
|
|
@ -164,13 +164,13 @@ func selfdestruct(pCtx unsafe.Pointer, pAddr *C.struct_evmc_address, pBeneficiar
|
|||
}
|
||||
|
||||
//export getTxContext
|
||||
func getTxContext(pResult unsafe.Pointer, pCtx unsafe.Pointer) {
|
||||
func getTxContext(pCtx unsafe.Pointer) C.struct_evmc_tx_context {
|
||||
idx := int((*C.struct_extended_context)(pCtx).index)
|
||||
ctx := getHostContext(idx)
|
||||
|
||||
gasPrice, origin, coinbase, number, timestamp, gasLimit, difficulty := ctx.GetTxContext()
|
||||
|
||||
*(*C.struct_evmc_tx_context)(pResult) = C.struct_evmc_tx_context{
|
||||
return C.struct_evmc_tx_context{
|
||||
evmcUint256be(gasPrice),
|
||||
evmcAddress(origin),
|
||||
evmcAddress(coinbase),
|
||||
|
|
|
@ -126,10 +126,12 @@ static struct evmc_result call(struct evmc_context* context, const struct evmc_m
|
|||
return result;
|
||||
}
|
||||
|
||||
static void get_tx_context(struct evmc_tx_context* result, struct evmc_context* context)
|
||||
static struct evmc_tx_context get_tx_context(struct evmc_context* context)
|
||||
{
|
||||
(void)result;
|
||||
(void)context;
|
||||
struct evmc_tx_context result;
|
||||
memset(&result, 0, sizeof(struct evmc_tx_context));
|
||||
return result;
|
||||
}
|
||||
|
||||
static void get_block_hash(struct evmc_uint256be* result,
|
||||
|
|
|
@ -145,13 +145,10 @@ struct evmc_context;
|
|||
* This callback function is used by an EVM to retrieve the transaction and
|
||||
* block context.
|
||||
*
|
||||
* @param[out] result The returned transaction context.
|
||||
* @see ::evmc_tx_context.
|
||||
* @param context The pointer to the Host execution context.
|
||||
* @see ::evmc_context.
|
||||
* @return The transaction context.
|
||||
*/
|
||||
typedef void (*evmc_get_tx_context_fn)(struct evmc_tx_context* result,
|
||||
struct evmc_context* context);
|
||||
typedef struct evmc_tx_context (*evmc_get_tx_context_fn)(struct evmc_context* context);
|
||||
|
||||
/**
|
||||
* Get block hash callback function.
|
||||
|
|
|
@ -97,10 +97,11 @@ static evmc_result call(evmc_context* context, const evmc_message* msg)
|
|||
return result;
|
||||
}
|
||||
|
||||
static void get_tx_context(evmc_tx_context* result, evmc_context* context)
|
||||
static evmc_tx_context get_tx_context(evmc_context* context)
|
||||
{
|
||||
(void)result;
|
||||
(void)context;
|
||||
evmc_tx_context result{};
|
||||
return result;
|
||||
}
|
||||
|
||||
static void get_block_hash(evmc_uint256be* result, evmc_context* context, int64_t number)
|
||||
|
|
Loading…
Reference in New Issue