aboutsummaryrefslogtreecommitdiffstats
path: root/core/execution.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-01 16:53:32 +0800
committerobscuren <geffobscura@gmail.com>2015-04-01 16:53:32 +0800
commit0a554a1f27ece4235d180373643482ceb57d90ca (patch)
tree6ab7d4cd70f7c49f64822d8e626f422158c70e78 /core/execution.go
parentd3e86f9208d775ee8020d5583d0aac8f3cfb52b2 (diff)
downloadgo-tangerine-0a554a1f27ece4235d180373643482ceb57d90ca.tar.gz
go-tangerine-0a554a1f27ece4235d180373643482ceb57d90ca.tar.zst
go-tangerine-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.go17
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)