forked from cerc-io/plugeth
New tx methods and added new vm to state manager
This commit is contained in:
parent
f567f89b99
commit
9cf8ce9ef8
@ -305,19 +305,17 @@ func (sm *StateManager) ProcessContract(contract *Contract, tx *Transaction, blo
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
*/
|
*/
|
||||||
|
caller := sm.procState.GetAccount(tx.Sender())
|
||||||
/*TODO to be fixed and replaced by the new vm
|
closure := NewClosure(caller, contract, sm.procState, tx.Gas, tx.Value)
|
||||||
vm := &Vm{}
|
vm := NewVm(sm.procState, RuntimeVars{
|
||||||
vm.Process(contract, sm.procState, RuntimeVars{
|
origin: caller.Address,
|
||||||
address: tx.Hash()[12:],
|
|
||||||
blockNumber: block.BlockInfo().Number,
|
blockNumber: block.BlockInfo().Number,
|
||||||
sender: tx.Sender(),
|
|
||||||
prevHash: block.PrevHash,
|
prevHash: block.PrevHash,
|
||||||
coinbase: block.Coinbase,
|
coinbase: block.Coinbase,
|
||||||
time: block.Time,
|
time: block.Time,
|
||||||
diff: block.Difficulty,
|
diff: block.Difficulty,
|
||||||
txValue: tx.Value,
|
// XXX Tx data? Could be just an argument to the closure instead
|
||||||
txData: tx.Data,
|
txData: nil,
|
||||||
})
|
})
|
||||||
*/
|
closure.Call(vm, nil)
|
||||||
}
|
}
|
||||||
|
@ -13,22 +13,31 @@ type Transaction struct {
|
|||||||
Nonce uint64
|
Nonce uint64
|
||||||
Recipient []byte
|
Recipient []byte
|
||||||
Value *big.Int
|
Value *big.Int
|
||||||
|
Gas *big.Int
|
||||||
|
Gasprice *big.Int
|
||||||
Data []string
|
Data []string
|
||||||
Memory []int
|
|
||||||
v byte
|
v byte
|
||||||
r, s []byte
|
r, s []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTransaction(to []byte, value *big.Int, data []string) *Transaction {
|
func NewTransaction(to []byte, value *big.Int, data []string) *Transaction {
|
||||||
tx := Transaction{Recipient: to, Value: value}
|
tx := Transaction{Recipient: to, Value: value, Nonce: 0, Data: data}
|
||||||
tx.Nonce = 0
|
|
||||||
|
|
||||||
// Serialize the data
|
|
||||||
tx.Data = data
|
|
||||||
|
|
||||||
return &tx
|
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
|
// XXX Deprecated
|
||||||
func NewTransactionFromData(data []byte) *Transaction {
|
func NewTransactionFromData(data []byte) *Transaction {
|
||||||
return NewTransactionFromBytes(data)
|
return NewTransactionFromBytes(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user