@@ -252,27 +252,6 @@ impl<M: Memory + Default, P: Patch> TransactionVM<M, P> {
252252 } )
253253 }
254254
255- /// Returns the real used gas by the transaction. This is what is
256- /// recorded in the transaction receipt.
257- pub fn real_used_gas ( & self ) -> Gas {
258- match self . 0 {
259- TransactionVMState :: Running { ref vm, intrinsic_gas, .. } => {
260- match vm. machines [ 0 ] . status ( ) {
261- MachineStatus :: ExitedErr ( _) =>
262- vm. machines [ 0 ] . state ( ) . context . gas_limit + intrinsic_gas,
263- MachineStatus :: ExitedOk => {
264- let total_used = vm. machines [ 0 ] . state ( ) . memory_gas ( ) + vm. machines [ 0 ] . state ( ) . used_gas + intrinsic_gas;
265- let refund_cap = total_used / Gas :: from ( 2u64 ) ;
266- let refunded = min ( refund_cap, vm. machines [ 0 ] . state ( ) . refunded_gas ) ;
267- total_used - refunded
268- }
269- _ => Gas :: zero ( ) ,
270- }
271- }
272- TransactionVMState :: Constructing { .. } => Gas :: zero ( ) ,
273- }
274- }
275-
276255 /// Returns the current state of the VM.
277256 pub fn current_state ( & self ) -> Option < & State < M , P > > {
278257 self . current_machine ( ) . map ( |m| m. state ( ) )
@@ -326,7 +305,7 @@ impl<M: Memory + Default, P: Patch> VM for TransactionVM<M, P> {
326305 let ccode_deposit: bool ;
327306 let cpreclaimed_value: U256 ;
328307
329- let real_used_gas = self . real_used_gas ( ) ;
308+ let real_used_gas = self . used_gas ( ) ;
330309
331310 match self . 0 {
332311 TransactionVMState :: Running {
@@ -454,6 +433,25 @@ impl<M: Memory + Default, P: Patch> VM for TransactionVM<M, P> {
454433 TransactionVMState :: Constructing { .. } => & [ ] ,
455434 }
456435 }
436+
437+ fn used_gas ( & self ) -> Gas {
438+ match self . 0 {
439+ TransactionVMState :: Running { ref vm, intrinsic_gas, .. } => {
440+ match vm. machines [ 0 ] . status ( ) {
441+ MachineStatus :: ExitedErr ( _) =>
442+ vm. machines [ 0 ] . state ( ) . context . gas_limit + intrinsic_gas,
443+ MachineStatus :: ExitedOk => {
444+ let total_used = vm. machines [ 0 ] . state ( ) . memory_gas ( ) + vm. machines [ 0 ] . state ( ) . used_gas + intrinsic_gas;
445+ let refund_cap = total_used / Gas :: from ( 2u64 ) ;
446+ let refunded = min ( refund_cap, vm. machines [ 0 ] . state ( ) . refunded_gas ) ;
447+ total_used - refunded
448+ }
449+ _ => Gas :: zero ( ) ,
450+ }
451+ }
452+ TransactionVMState :: Constructing { .. } => Gas :: zero ( ) ,
453+ }
454+ }
457455}
458456
459457#[ cfg( test) ]
0 commit comments