diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-01 16:53:32 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-01 16:53:32 +0800 |
commit | 0a554a1f27ece4235d180373643482ceb57d90ca (patch) | |
tree | 6ab7d4cd70f7c49f64822d8e626f422158c70e78 /core/execution.go | |
parent | d3e86f9208d775ee8020d5583d0aac8f3cfb52b2 (diff) | |
download | dexon-0a554a1f27ece4235d180373643482ceb57d90ca.tar dexon-0a554a1f27ece4235d180373643482ceb57d90ca.tar.gz dexon-0a554a1f27ece4235d180373643482ceb57d90ca.tar.bz2 dexon-0a554a1f27ece4235d180373643482ceb57d90ca.tar.lz dexon-0a554a1f27ece4235d180373643482ceb57d90ca.tar.xz dexon-0a554a1f27ece4235d180373643482ceb57d90ca.tar.zst dexon-0a554a1f27ece4235d180373643482ceb57d90ca.zip |
Blocktest fixed, Execution fixed
* Added new CreateAccount method which properly overwrites previous
accounts (excluding balance)
* Fixed block tests (100% success)
Diffstat (limited to 'core/execution.go')
-rw-r--r-- | core/execution.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/core/execution.go b/core/execution.go index 24e085e6d..93fb03ecc 100644 --- a/core/execution.go +++ b/core/execution.go @@ -50,16 +50,29 @@ func (self *Execution) exec(contextAddr *common.Address, code []byte, caller vm. } vsnapshot := env.State().Copy() + var createAccount bool if self.address == nil { // Generate a new address nonce := env.State().GetNonce(caller.Address()) - addr := crypto.CreateAddress(caller.Address(), nonce) env.State().SetNonce(caller.Address(), nonce+1) + + addr := crypto.CreateAddress(caller.Address(), nonce) + self.address = &addr + createAccount = true } snapshot := env.State().Copy() - from, to := env.State().GetStateObject(caller.Address()), env.State().GetOrNewStateObject(*self.address) + var ( + from = env.State().GetStateObject(caller.Address()) + to *state.StateObject + ) + if createAccount { + to = env.State().CreateAccount(*self.address) + } else { + to = env.State().GetOrNewStateObject(*self.address) + } + err = env.Transfer(from, to, self.value) if err != nil { env.State().Set(vsnapshot) |