From 3520771d68df1e9becfb29cc2f85d7042f3fb9d1 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 20 Mar 2014 17:27:09 +0100 Subject: Comply to Callee interface --- ethchain/transaction.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'ethchain/transaction.go') diff --git a/ethchain/transaction.go b/ethchain/transaction.go index 57df9cdc4..07e7ea970 100644 --- a/ethchain/transaction.go +++ b/ethchain/transaction.go @@ -29,6 +29,15 @@ func NewTransaction(to []byte, value *big.Int, data []string) *Transaction { return &tx } +// Implements Callee +func (tx *Transaction) ReturnGas(value *big.Int, state *State) { + // Return the value back to the sender + sender := tx.Sender() + account := state.GetAccount(sender) + account.AddFunds(value) + state.UpdateAccount(sender, account) +} + // XXX Deprecated func NewTransactionFromData(data []byte) *Transaction { return NewTransactionFromBytes(data) -- cgit v1.2.3 From 7705b23f248156878d00c301fbbadafedaf7e3d2 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 20 Mar 2014 23:17:53 +0100 Subject: Removed caller from tx and added "callership" to account. Transactions can no longer serve as callers. Accounts are now the initial callee of closures. Transactions now serve as transport to call closures. --- ethchain/transaction.go | 9 --------- 1 file changed, 9 deletions(-) (limited to 'ethchain/transaction.go') diff --git a/ethchain/transaction.go b/ethchain/transaction.go index 07e7ea970..57df9cdc4 100644 --- a/ethchain/transaction.go +++ b/ethchain/transaction.go @@ -29,15 +29,6 @@ func NewTransaction(to []byte, value *big.Int, data []string) *Transaction { return &tx } -// Implements Callee -func (tx *Transaction) ReturnGas(value *big.Int, state *State) { - // Return the value back to the sender - sender := tx.Sender() - account := state.GetAccount(sender) - account.AddFunds(value) - state.UpdateAccount(sender, account) -} - // XXX Deprecated func NewTransactionFromData(data []byte) *Transaction { return NewTransactionFromBytes(data) -- cgit v1.2.3 From 9cf8ce9ef82bfb37fea92bbea6a8d326af00adc8 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 21 Mar 2014 00:04:31 +0100 Subject: New tx methods and added new vm to state manager --- ethchain/transaction.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'ethchain/transaction.go') 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) -- cgit v1.2.3