Merge pull request #64 from ethereum/examples

examples: update capi for latest interface
This commit is contained in:
Paweł Bylica 2018-08-20 11:39:54 +02:00 committed by GitHub
commit 6dca3222da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -1,4 +1,5 @@
#include <evmc/evmc.h>
#include <evmc/helpers.h>
#include <inttypes.h>
#include <stdio.h>
@ -165,8 +166,8 @@ static const struct evmc_context_fn_table ctx_fn_table = {
/// Example how the API is supposed to be used.
int main()
{
struct evmc_instance* jit = evmc_create_examplevm();
if (jit->abi_version != EVMC_ABI_VERSION)
struct evmc_instance* vm = evmc_create_examplevm();
if (vm->abi_version != EVMC_ABI_VERSION)
return 1; // Incompatible ABI version.
const uint8_t code[] = "Place some EVM bytecode here";
@ -189,7 +190,7 @@ int main()
msg.gas = gas;
msg.depth = 0;
struct evmc_result result = jit->execute(jit, &ctx, EVMC_HOMESTEAD, &msg, code, code_size);
struct evmc_result result = vm->execute(vm, &ctx, EVMC_HOMESTEAD, &msg, code, code_size);
printf("Execution result:\n");
if (result.status_code != EVMC_SUCCESS)
@ -209,9 +210,8 @@ int main()
printf("\n");
}
if (result.release)
result.release(&result);
jit->destroy(jit);
evmc_release_result(&result);
evmc_destroy(vm);
return 0;
}