core, core/state: move gas tracking out of core/state

The amount of gas available for tx execution was tracked in the
StateObject representing the coinbase account. This commit makes the gas
counter a separate type in package core, which avoids unintended
consequences of intertwining the counter with state logic.
This commit is contained in:
Felix Lange
2015-09-02 12:55:11 +02:00
parent 10ed107ba2
commit de8d5aaa92
10 changed files with 92 additions and 142 deletions

View File

@ -188,3 +188,16 @@ func IsBadHashError(err error) bool {
_, ok := err.(BadHashError)
return ok
}
type GasLimitErr struct {
Have, Want *big.Int
}
func IsGasLimitErr(err error) bool {
_, ok := err.(*GasLimitErr)
return ok
}
func (err *GasLimitErr) Error() string {
return fmt.Sprintf("GasLimit reached. Have %d gas, transaction requires %d", err.Have, err.Want)
}