basic structure in place

This commit is contained in:
rigelrozanski
2018-11-13 11:30:06 -05:00
parent 2f73cf4193
commit 956d351f68
2 changed files with 19 additions and 6 deletions
+9
View File
@@ -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