New tx methods and added new vm to state manager

pull/150/head
obscuren 11 years ago
parent f567f89b99
commit 9cf8ce9ef8
  1. 16
      ethchain/state_manager.go
  2. 21
      ethchain/transaction.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)
}

@ -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)

Loading…
Cancel
Save