diff options
author | obscuren <geffobscura@gmail.com> | 2014-04-16 10:06:51 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-04-16 10:06:51 +0800 |
commit | 9c6aca78933c14ca107da30c4690808950718368 (patch) | |
tree | da641b2904ea6ed05870a1ded486543529eae5a3 /ethchain/address.go | |
parent | ca13e3b1058f0d680b79dc1d9319d427a09493f8 (diff) | |
download | go-tangerine-9c6aca78933c14ca107da30c4690808950718368.tar go-tangerine-9c6aca78933c14ca107da30c4690808950718368.tar.gz go-tangerine-9c6aca78933c14ca107da30c4690808950718368.tar.bz2 go-tangerine-9c6aca78933c14ca107da30c4690808950718368.tar.lz go-tangerine-9c6aca78933c14ca107da30c4690808950718368.tar.xz go-tangerine-9c6aca78933c14ca107da30c4690808950718368.tar.zst go-tangerine-9c6aca78933c14ca107da30c4690808950718368.zip |
Merged accounts and contracts in to StateObject
* Account removed
* Contract removed
* Address state changed to CachedStateObject
* Added StateObject
Diffstat (limited to 'ethchain/address.go')
-rw-r--r-- | ethchain/address.go | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/ethchain/address.go b/ethchain/address.go deleted file mode 100644 index 0b3ef7c05..000000000 --- a/ethchain/address.go +++ /dev/null @@ -1,76 +0,0 @@ -package ethchain - -import ( - "github.com/ethereum/eth-go/ethutil" - "math/big" -) - -type Account struct { - address []byte - Amount *big.Int - Nonce uint64 -} - -func NewAccount(address []byte, amount *big.Int) *Account { - return &Account{address, amount, 0} -} - -func NewAccountFromData(address, data []byte) *Account { - account := &Account{address: address} - account.RlpDecode(data) - - return account -} - -func (a *Account) AddFee(fee *big.Int) { - a.AddFunds(fee) -} - -func (a *Account) AddFunds(funds *big.Int) { - a.Amount.Add(a.Amount, funds) -} - -func (a *Account) Address() []byte { - return a.address -} - -// 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}) -} - -func (a *Account) RlpDecode(data []byte) { - decoder := ethutil.NewValueFromBytes(data) - - a.Amount = decoder.Get(0).BigInt() - a.Nonce = decoder.Get(1).Uint() -} - -type AddrStateStore struct { - states map[string]*AccountState -} - -func NewAddrStateStore() *AddrStateStore { - return &AddrStateStore{states: make(map[string]*AccountState)} -} - -func (s *AddrStateStore) Add(addr []byte, account *Account) *AccountState { - state := &AccountState{Nonce: account.Nonce, Account: account} - s.states[string(addr)] = state - return state -} - -func (s *AddrStateStore) Get(addr []byte) *AccountState { - return s.states[string(addr)] -} - -type AccountState struct { - Nonce uint64 - Account *Account -} |