basic structure in place
This commit is contained in:
@@ -29,6 +29,7 @@ type ErrorOutOfGas struct {
|
||||
type GasMeter interface {
|
||||
GasConsumed() Gas
|
||||
ConsumeGas(amount Gas, descriptor string)
|
||||
PastLimit() bool
|
||||
}
|
||||
|
||||
type basicGasMeter struct {
|
||||
@@ -55,6 +56,10 @@ func (g *basicGasMeter) ConsumeGas(amount Gas, descriptor string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (g *basicGasMeter) PastLimit() bool {
|
||||
return g.consumed > g.limit
|
||||
}
|
||||
|
||||
type infiniteGasMeter struct {
|
||||
consumed Gas
|
||||
}
|
||||
@@ -74,6 +79,10 @@ func (g *infiniteGasMeter) ConsumeGas(amount Gas, descriptor string) {
|
||||
g.consumed += amount
|
||||
}
|
||||
|
||||
func (g *infiniteGasMeter) PastLimit() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// GasConfig defines gas cost for each operation on KVStores
|
||||
type GasConfig struct {
|
||||
HasCost Gas
|
||||
|
||||
Reference in New Issue
Block a user