aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-03-21 07:04:31 +0800
committerobscuren <geffobscura@gmail.com>2014-03-21 07:04:31 +0800
commit9cf8ce9ef82bfb37fea92bbea6a8d326af00adc8 (patch)
tree4816383a97b754199430184e6b245e51ea529bd7
parentf567f89b994bf28f908410223084a6702d05d156 (diff)
downloadgo-tangerine-9cf8ce9ef82bfb37fea92bbea6a8d326af00adc8.tar.gz
go-tangerine-9cf8ce9ef82bfb37fea92bbea6a8d326af00adc8.tar.zst
go-tangerine-9cf8ce9ef82bfb37fea92bbea6a8d326af00adc8.zip
New tx methods and added new vm to state manager
-rw-r--r--ethchain/state_manager.go16
-rw-r--r--ethchain/transaction.go21
2 files changed, 22 insertions, 15 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go
index 14686b217..50c777349 100644
--- a/ethchain/state_manager.go
+++ b/ethchain/state_manager.go
@@ -305,19 +305,17 @@ func (sm *StateManager) ProcessContract(contract *Contract, tx *Transaction, blo
}
}()
*/
-
- /*TODO to be fixed and replaced by the new vm
- vm := &Vm{}
- vm.Process(contract, sm.procState, RuntimeVars{
- address: tx.Hash()[12:],
+ caller := sm.procState.GetAccount(tx.Sender())
+ closure := NewClosure(caller, contract, sm.procState, tx.Gas, tx.Value)
+ vm := NewVm(sm.procState, RuntimeVars{
+ origin: caller.Address,
blockNumber: block.BlockInfo().Number,
- sender: tx.Sender(),
prevHash: block.PrevHash,
coinbase: block.Coinbase,
time: block.Time,
diff: block.Difficulty,
- txValue: tx.Value,
- txData: tx.Data,
+ // XXX Tx data? Could be just an argument to the closure instead
+ txData: nil,
})
- */
+ closure.Call(vm, nil)
}
diff --git a/ethchain/transaction.go b/ethchain/transaction.go
index 57df9cdc4..3b07c81d4 100644
--- a/ethchain/transaction.go
+++ b/ethchain/transaction.go
@@ -13,22 +13,31 @@ type Transaction struct {
Nonce uint64
Recipient []byte
Value *big.Int
+ Gas *big.Int
+ Gasprice *big.Int
Data []string
- Memory []int
v byte
r, s []byte
}
func NewTransaction(to []byte, value *big.Int, data []string) *Transaction {
- tx := Transaction{Recipient: to, Value: value}
- tx.Nonce = 0
-
- // Serialize the data
- tx.Data = data
+ tx := Transaction{Recipient: to, Value: value, Nonce: 0, Data: data}
return &tx
}
+func NewContractCreationTx(value, gasprice *big.Int, data []string) *Transaction {
+ return &Transaction{Value: value, Gasprice: gasprice, Data: data}
+}
+
+func NewContractMessageTx(to []byte, value, gasprice, gas *big.Int, data []string) *Transaction {
+ return &Transaction{Recipient: to, Value: value, Gasprice: gasprice, Gas: gas, Data: data}
+}
+
+func NewTx(to []byte, value *big.Int, data []string) *Transaction {
+ return &Transaction{Recipient: to, Value: value, Gasprice: big.NewInt(0), Gas: big.NewInt(0), Nonce: 0, Data: data}
+}
+
// XXX Deprecated
func NewTransactionFromData(data []byte) *Transaction {
return NewTransactionFromBytes(data)