From 168b5be829acace7e03653519ac4fda83372a82c Mon Sep 17 00:00:00 2001 From: fro Date: Wed, 15 Aug 2018 16:36:01 +0300 Subject: [PATCH] gasleft extern added --- src/ext.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ext.rs b/src/ext.rs index 319d71d6..3c6e1325 100644 --- a/src/ext.rs +++ b/src/ext.rs @@ -62,6 +62,8 @@ mod external { pub fn gaslimit(dest: *mut u8); + pub fn gasleft() -> i64; + pub fn sender(dest: *mut u8); pub fn address(dest: *mut u8); @@ -253,6 +255,11 @@ pub fn gas_limit() -> U256 { unsafe { fetch_u256(|x| external::gaslimit(x) ) } } +/// Get amount of gas left. +pub fn gas_left() -> u64 { + unsafe { external::gasleft() as u64 } +} + /// Get caller address /// /// This is the address of the account that is directly responsible for this execution.