core, tests: reduced state copy by N calls
Reduced the amount of state copied that are required by N calls by doing a balance check prior to any state modifications.
This commit is contained in:
@ -36,6 +36,7 @@ type Environment interface {
|
||||
Time() uint64
|
||||
Difficulty() *big.Int
|
||||
GasLimit() *big.Int
|
||||
CanTransfer(from Account, balance *big.Int) bool
|
||||
Transfer(from, to Account, amount *big.Int) error
|
||||
AddLog(*state.Log)
|
||||
AddStructLog(StructLog)
|
||||
|
@ -13,6 +13,7 @@
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package vm
|
||||
|
||||
import (
|
||||
|
@ -13,6 +13,7 @@
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package vm
|
||||
|
||||
import (
|
||||
@ -48,7 +49,7 @@ func SetJITCacheSize(size int) {
|
||||
programs, _ = lru.New(size)
|
||||
}
|
||||
|
||||
// GetProgram returns the program by id or nil when non-existant
|
||||
// GetProgram returns the program by id or nil when non-existent
|
||||
func GetProgram(id common.Hash) *Program {
|
||||
if p, ok := programs.Get(id); ok {
|
||||
return p.(*Program)
|
||||
|
@ -105,6 +105,9 @@ func (self *Env) AddLog(log *state.Log) {
|
||||
}
|
||||
func (self *Env) Depth() int { return self.depth }
|
||||
func (self *Env) SetDepth(i int) { self.depth = i }
|
||||
func (self *Env) CanTransfer(from Account, balance *big.Int) bool {
|
||||
return from.Balance().Cmp(balance) >= 0
|
||||
}
|
||||
func (self *Env) Transfer(from, to Account, amount *big.Int) error {
|
||||
return nil
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package vm
|
||||
|
||||
var (
|
||||
|
Reference in New Issue
Block a user