mirror of https://github.com/status-im/evmc.git
Merge pull request #68 from ethereum/abi-version-helper
Add evmc_is_abi_compatible helper
This commit is contained in:
commit
36b7976121
|
@ -167,8 +167,8 @@ static const struct evmc_context_fn_table ctx_fn_table = {
|
|||
int main()
|
||||
{
|
||||
struct evmc_instance* vm = evmc_create_examplevm();
|
||||
if (vm->abi_version != EVMC_ABI_VERSION)
|
||||
return 1; // Incompatible ABI version.
|
||||
if (!evmc_is_abi_compatible(vm))
|
||||
return 1;
|
||||
|
||||
const uint8_t code[] = "Place some EVM bytecode here";
|
||||
const size_t code_size = sizeof(code);
|
||||
|
|
|
@ -17,6 +17,14 @@
|
|||
|
||||
#include <evmc/evmc.h>
|
||||
|
||||
/**
|
||||
* Returns true if the instance has a compatible ABI version.
|
||||
*/
|
||||
static inline int evmc_is_abi_compatible(struct evmc_instance *instance)
|
||||
{
|
||||
return instance->abi_version == EVMC_ABI_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the VM instance.
|
||||
*
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <evmc/loader.h>
|
||||
#include <evmc/evmc.h>
|
||||
#include <evmc/helpers.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
@ -137,7 +138,7 @@ struct evmc_instance* evmc_load_and_create(const char* filename, enum evmc_loade
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (instance->abi_version != EVMC_ABI_VERSION)
|
||||
if (!evmc_is_abi_compatible(instance))
|
||||
{
|
||||
*error_code = EVMC_LOADER_ABI_VERSION_MISMATCH;
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue