Skip to content

Commit

Permalink
Merge pull request #553 from ethereum/java-accountexists
Browse files Browse the repository at this point in the history
java: change Host.account_exists to return boolean
  • Loading branch information
axic committed Oct 10, 2020
2 parents 57bbfb5 + 03c30bf commit cd9be61
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions bindings/java/c/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static void CopyFromByteBuffer(JNIEnv* jenv, jobject src, void* dst, size_t size
static bool account_exists_fn(struct evmc_host_context* context, const evmc_address* address)
{
const char java_method_name[] = "account_exists";
const char java_method_signature[] = "(I[B)I";
const char java_method_signature[] = "(I[B)Z";

assert(context != NULL);
JNIEnv* jenv = attach();
Expand All @@ -70,7 +70,8 @@ static bool account_exists_fn(struct evmc_host_context* context, const evmc_addr
jbyteArray jaddress = CopyDataToJava(jenv, address, sizeof(struct evmc_address));

// call java method
jint jresult = (*jenv)->CallStaticIntMethod(jenv, host_class, method, context->index, jaddress);
jboolean jresult =
(*jenv)->CallStaticBooleanMethod(jenv, host_class, method, context->index, jaddress);
return jresult != 0;
}

Expand Down
4 changes: 2 additions & 2 deletions bindings/java/java/src/main/java/org/ethereum/evmc/Host.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
*/
final class Host {
/** Check account existence callback function. */
static int account_exists(int context_index, byte[] address) {
static boolean account_exists(int context_index, byte[] address) {
HostContext context =
requireNonNull(
getContext(context_index),
"HostContext does not exist for context_index: " + context_index);
return context.accountExists(address) ? 1 : 0;
return context.accountExists(address);
}

/** Get storage callback function. */
Expand Down

0 comments on commit cd9be61

Please sign in to comment.