diff options
author | obscuren <geffobscura@gmail.com> | 2014-03-03 18:35:35 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-03-03 18:35:35 +0800 |
commit | 5b1613d65b0c3471b80990120022b5a745ecab86 (patch) | |
tree | addbb87cc82cca07e8ac8aa810d810e1de02b2a5 /ethchain/address.go | |
parent | d7c5936ac4ee8ae3156e0bc9813db61b990aa686 (diff) | |
parent | c1d0ea7366f1bad134c985dbe1f272d376e5ec9b (diff) | |
download | dexon-5b1613d65b0c3471b80990120022b5a745ecab86.tar dexon-5b1613d65b0c3471b80990120022b5a745ecab86.tar.gz dexon-5b1613d65b0c3471b80990120022b5a745ecab86.tar.bz2 dexon-5b1613d65b0c3471b80990120022b5a745ecab86.tar.lz dexon-5b1613d65b0c3471b80990120022b5a745ecab86.tar.xz dexon-5b1613d65b0c3471b80990120022b5a745ecab86.tar.zst dexon-5b1613d65b0c3471b80990120022b5a745ecab86.zip |
Merge branch 'master' into develop
Diffstat (limited to 'ethchain/address.go')
-rw-r--r-- | ethchain/address.go | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/ethchain/address.go b/ethchain/address.go index a228c7566..aa1709f2c 100644 --- a/ethchain/address.go +++ b/ethchain/address.go @@ -5,31 +5,31 @@ import ( "math/big" ) -type Address struct { +type Account struct { Amount *big.Int Nonce uint64 } -func NewAddress(amount *big.Int) *Address { - return &Address{Amount: amount, Nonce: 0} +func NewAccount(amount *big.Int) *Account { + return &Account{Amount: amount, Nonce: 0} } -func NewAddressFromData(data []byte) *Address { - address := &Address{} +func NewAccountFromData(data []byte) *Account { + address := &Account{} address.RlpDecode(data) return address } -func (a *Address) AddFee(fee *big.Int) { +func (a *Account) AddFee(fee *big.Int) { a.Amount.Add(a.Amount, fee) } -func (a *Address) RlpEncode() []byte { +func (a *Account) RlpEncode() []byte { return ethutil.Encode([]interface{}{a.Amount, a.Nonce}) } -func (a *Address) RlpDecode(data []byte) { +func (a *Account) RlpDecode(data []byte) { decoder := ethutil.NewValueFromBytes(data) a.Amount = decoder.Get(0).BigInt() @@ -37,24 +37,24 @@ func (a *Address) RlpDecode(data []byte) { } type AddrStateStore struct { - states map[string]*AddressState + states map[string]*AccountState } func NewAddrStateStore() *AddrStateStore { - return &AddrStateStore{states: make(map[string]*AddressState)} + return &AddrStateStore{states: make(map[string]*AccountState)} } -func (s *AddrStateStore) Add(addr []byte, account *Address) *AddressState { - state := &AddressState{Nonce: account.Nonce, Account: account} +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) *AddressState { +func (s *AddrStateStore) Get(addr []byte) *AccountState { return s.states[string(addr)] } -type AddressState struct { +type AccountState struct { Nonce uint64 - Account *Address + Account *Account } |