gas

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2023 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Overview

Package gas provides a basic API for app modules to track gas usage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gas

type Gas = uint64

type Meter

type Meter interface {
	GasConsumed() Gas
	GasConsumedToLimit() Gas
	GasRemaining() Gas
	Limit() Gas
	ConsumeGas(amount Gas, descriptor string)
	RefundGas(amount Gas, descriptor string)
	IsPastLimit() bool
	IsOutOfGas() bool
	String() string
}

Meter represents a gas meter.

type Service

type Service interface {
	// GetGasMeter returns the current transaction-level gas meter. A non-nil meter
	// is always returned. When one is unavailable in the context an infinite gas meter
	// will be returned.
	GetGasMeter(context.Context) Meter

	// GetBlockGasMeter returns the current block-level gas meter. A non-nil meter
	// is always returned. When one is unavailable in the context an infinite gas meter
	// will be returned.
	GetBlockGasMeter(context.Context) Meter

	// WithGasMeter returns a new context with the provided transaction-level gas meter.
	WithGasMeter(ctx context.Context, meter Meter) context.Context

	// WithBlockGasMeter returns a new context with the provided block-level gas meter.
	WithBlockGasMeter(ctx context.Context, meter Meter) context.Context
}

Service represents a gas service which can retrieve and set a gas meter in a context. gas.Service is a core API type that should be provided by the runtime module being used to build an app via depinject.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL