pub fn reserve_gas(amount: u64, duration: u32) -> Result<ReservationId, Error>Available on non-crate feature
ethexe only.Expand description
Reserve the amount of gas for further usage.
duration is the block count within which the reserve must be used.
This function returns ReservationId, which one can use for gas
unreserving.
§Examples
Reserve 50 million of gas for seven blocks:
use gcore::{ReservationId, exec};
static mut RESERVED: ReservationId = ReservationId::zero();
#[unsafe(no_mangle)]
extern "C" fn init() {
unsafe { RESERVED = exec::reserve_gas(50_000_000, 7).unwrap() };
}
#[unsafe(no_mangle)]
extern "C" fn handle() {
exec::unreserve_gas(unsafe { RESERVED }).expect("Unable to unreserve");
}§See also
unreserve_gasfunction unreserves gas identified byReservationId.system_reserve_gasfunction reserves gas for system usage.