From c1259c1f11c137a418514f09f95186189ab89447 Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 17 Aug 2023 11:29:53 +0200 Subject: [PATCH] Add constructor for gas report --- types/types.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/types/types.go b/types/types.go index cfc3ed857..1acd29d83 100644 --- a/types/types.go +++ b/types/types.go @@ -122,12 +122,19 @@ type GasReport struct { UsedInternally uint64 } +// EmptyGasReport creates a new GasReport with the given limit and 0 gas used. func EmptyGasReport(limit uint64) GasReport { + return NewGasReport(limit, 0) +} + +// NewGasReport creates a new GasReport with the given limit and amount of gas used internally. +// UsedExternally is set to 0. +func NewGasReport(limit uint64, usedInternally uint64) GasReport { return GasReport{ Limit: limit, - Remaining: limit, + Remaining: limit - usedInternally, UsedExternally: 0, - UsedInternally: 0, + UsedInternally: usedInternally, } }