Skip to content

Commit b4d3a0c

Browse files
author
Eduardo Leegwater Simões
committed
contracts: add host_get_counter to host contract
1 parent 1e7fbdf commit b4d3a0c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

contracts/host/src/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ impl Hoster {
4545
false => String::from("PROOF IS INVALID"),
4646
}
4747
}
48+
49+
/// Call 'get_counter' function available from the host, and return the
50+
/// result
51+
pub fn host_get_counter(&self) -> i64 {
52+
uplink::host_query("get_counter", ())
53+
}
4854
}
4955

5056
/// Expose `Hoster::host_hash()` to the host
@@ -60,3 +66,9 @@ unsafe fn host_verify(arg_len: u32) -> u32 {
6066
STATE.host_verify(proof, public_inputs)
6167
})
6268
}
69+
70+
/// Expose `Hoster::host_counter()` to the host
71+
#[no_mangle]
72+
unsafe fn host_get_counter(arg_len: u32) -> u32 {
73+
uplink::wrap_call(arg_len, |()| STATE.host_get_counter())
74+
}

0 commit comments

Comments
 (0)