Skip to content

Commit

Permalink
contracts: add host_get_counter to host contract
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduardo Leegwater Simões committed Feb 10, 2024
1 parent c4b7675 commit 896e90e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions contracts/host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ impl Hoster {
false => String::from("PROOF IS INVALID"),
}
}

/// Call 'get_counter' function available from the host, and return the
/// result
pub fn host_get_counter(&self) -> i64 {
uplink::host_query("get_counter", ())
}
}

/// Expose `Hoster::host_hash()` to the host
Expand All @@ -60,3 +66,9 @@ unsafe fn host_verify(arg_len: u32) -> u32 {
STATE.host_verify(proof, public_inputs)
})
}

/// Expose `Hoster::host_counter()` to the host
#[no_mangle]
unsafe fn host_get_counter(arg_len: u32) -> u32 {
uplink::wrap_call(arg_len, |()| STATE.host_get_counter())
}

0 comments on commit 896e90e

Please sign in to comment.