diff options
author | obscuren <geffobscura@gmail.com> | 2014-03-21 06:17:53 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-03-21 06:17:53 +0800 |
commit | 7705b23f248156878d00c301fbbadafedaf7e3d2 (patch) | |
tree | 11f3373c598106b9f6f689370079a9b220a42e34 /ethchain/address.go | |
parent | f3d27bf5d878120346f8cdd0744e7f1f8e1ee631 (diff) | |
download | dexon-7705b23f248156878d00c301fbbadafedaf7e3d2.tar dexon-7705b23f248156878d00c301fbbadafedaf7e3d2.tar.gz dexon-7705b23f248156878d00c301fbbadafedaf7e3d2.tar.bz2 dexon-7705b23f248156878d00c301fbbadafedaf7e3d2.tar.lz dexon-7705b23f248156878d00c301fbbadafedaf7e3d2.tar.xz dexon-7705b23f248156878d00c301fbbadafedaf7e3d2.tar.zst dexon-7705b23f248156878d00c301fbbadafedaf7e3d2.zip |
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.
Diffstat (limited to 'ethchain/address.go')
-rw-r--r-- | ethchain/address.go | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/ethchain/address.go b/ethchain/address.go index f1f27a1a5..9c6acbe08 100644 --- a/ethchain/address.go +++ b/ethchain/address.go @@ -6,19 +6,20 @@ import ( ) type Account struct { - Amount *big.Int - Nonce uint64 + Address []byte + Amount *big.Int + Nonce uint64 } -func NewAccount(amount *big.Int) *Account { - return &Account{Amount: amount, Nonce: 0} +func NewAccount(address []byte, amount *big.Int) *Account { + return &Account{address, amount, 0} } -func NewAccountFromData(data []byte) *Account { - address := &Account{} - address.RlpDecode(data) +func NewAccountFromData(address, data []byte) *Account { + account := &Account{Address: address} + account.RlpDecode(data) - return address + return account } func (a *Account) AddFee(fee *big.Int) { @@ -29,6 +30,13 @@ func (a *Account) AddFunds(funds *big.Int) { a.Amount.Add(a.Amount, funds) } +// Implements Callee +func (a *Account) ReturnGas(value *big.Int, state *State) { + // Return the value back to the sender + a.AddFunds(value) + state.UpdateAccount(a.Address, a) +} + func (a *Account) RlpEncode() []byte { return ethutil.Encode([]interface{}{a.Amount, a.Nonce}) } |