diff options
author | obscuren <geffobscura@gmail.com> | 2014-04-23 21:53:53 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-04-23 21:53:53 +0800 |
commit | c81804444f69ae1653d54551d8555ff924651cd9 (patch) | |
tree | c0c19316adb648eccb9696b1c953531d06a8b11f /ethchain | |
parent | ef7f3f36e261bc500016dac0a703c5b7931a1721 (diff) | |
download | dexon-c81804444f69ae1653d54551d8555ff924651cd9.tar.gz dexon-c81804444f69ae1653d54551d8555ff924651cd9.tar.zst dexon-c81804444f69ae1653d54551d8555ff924651cd9.zip |
Call initial closure with proper tx argument
Diffstat (limited to 'ethchain')
-rw-r--r-- | ethchain/block_chain.go | 1 | ||||
-rw-r--r-- | ethchain/state_manager.go | 33 | ||||
-rw-r--r-- | ethchain/vm.go | 4 |
3 files changed, 5 insertions, 33 deletions
diff --git a/ethchain/block_chain.go b/ethchain/block_chain.go index d65c38fe4..08886c9cd 100644 --- a/ethchain/block_chain.go +++ b/ethchain/block_chain.go @@ -46,6 +46,7 @@ func (bc *BlockChain) NewBlock(coinbase []byte, txs []*Transaction) *Block { hash = bc.LastBlockHash lastBlockTime = bc.CurrentBlock.Time } + block := CreateBlock( root, hash, diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go index 23da77fae..668a44c3f 100644 --- a/ethchain/state_manager.go +++ b/ethchain/state_manager.go @@ -133,37 +133,6 @@ func (sm *StateManager) ApplyTransactions(block *Block, txs []*Transaction) { } } } - // Process each transaction/contract - for _, tx := range txs { - // If there's no recipient, it's a contract - // Check if this is a contract creation traction and if so - // create a contract of this tx. - if tx.IsContract() { - contract := sm.MakeContract(tx) - if contract != nil { - sm.EvalScript(contract.Init(), contract, tx, block) - } else { - ethutil.Config.Log.Infoln("[STATE] Unable to create contract") - } - } else { - // Figure out if the address this transaction was sent to is a - // contract or an actual account. In case of a contract, we process that - // contract instead of moving funds between accounts. - var err error - if contract := sm.procState.GetContract(tx.Recipient); contract != nil { - err = sm.Ethereum.TxPool().ProcessTransaction(tx, block, true) - if err == nil { - sm.EvalScript(contract.Script(), contract, tx, block) - } - } else { - err = sm.Ethereum.TxPool().ProcessTransaction(tx, block, false) - } - - if err != nil { - ethutil.Config.Log.Infoln("[STATE]", err) - } - } - } } // The prepare function, prepares the state manager for the next @@ -359,7 +328,7 @@ func (sm *StateManager) EvalScript(script []byte, object *StateObject, tx *Trans Diff: block.Difficulty, //Price: tx.GasPrice, }) - closure.Call(vm, nil, nil) + closure.Call(vm, tx.Data, nil) // Update the account (refunds) sm.procState.UpdateStateObject(caller) diff --git a/ethchain/vm.go b/ethchain/vm.go index 33541cb3b..90b591f50 100644 --- a/ethchain/vm.go +++ b/ethchain/vm.go @@ -53,11 +53,12 @@ var isRequireError = false func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err error) { // Recover from any require exception defer func() { - if r := recover(); r != nil && isRequireError { + if r := recover(); r != nil /*&& isRequireError*/ { fmt.Println(r) ret = closure.Return(nil) err = fmt.Errorf("%v", r) + fmt.Println("vm err", err) } }() @@ -315,6 +316,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro case oCALLDATALOAD: require(1) offset := stack.Pop().Int64() + fmt.Println(closure.Args) val := closure.Args[offset : offset+31] stack.Push(ethutil.BigD(val)) |