From e2b99999437d0d8a9ea83fa359cd79b4b48335de Mon Sep 17 00:00:00 2001 From: codchen Date: Wed, 12 Jul 2023 11:56:45 +0800 Subject: [PATCH] Add NoConsumptionInfiniteGasMeter --- store/types/gas.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/store/types/gas.go b/store/types/gas.go index 6966387a8..ef2283964 100644 --- a/store/types/gas.go +++ b/store/types/gas.go @@ -272,6 +272,31 @@ func (g *infiniteGasMeter) String() string { return fmt.Sprintf("InfiniteGasMeter:\n consumed: %d", g.consumed) } +type noConsumptionInfiniteGasMeter struct { + infiniteGasMeter +} + +func NewNoConsumptionInfiniteGasMeter() GasMeter { + return &noConsumptionInfiniteGasMeter{ + infiniteGasMeter: infiniteGasMeter{ + consumed: 0, + lock: &sync.Mutex{}, + }, + } +} + +func (g *noConsumptionInfiniteGasMeter) GasConsumed() Gas { + return 0 +} + +func (g *noConsumptionInfiniteGasMeter) GasConsumedToLimit() Gas { + return 0 +} + +func (g *noConsumptionInfiniteGasMeter) ConsumeGas(amount Gas, descriptor string) {} + +func (g *noConsumptionInfiniteGasMeter) RefundGas(amount Gas, descriptor string) {} + // GasConfig defines gas cost for each operation on KVStores type GasConfig struct { HasCost Gas