Documentation ¶
Index ¶
- Constants
- Variables
- func KeyTrieToSlice(trie *trie.Batch) [][]byte
- type Account
- type AccountState
- func (as *AccountState) Accounts() ([]*Account, error)
- func (as *AccountState) Clone() (*AccountState, error)
- func (as *AccountState) DelAccountAlias(alias string, addr common.Address) error
- func (as *AccountState) GetAccount(addr common.Address, timestamp int64) (*Account, error)
- func (as *AccountState) GetAccountByAlias(alias string, timestamp int64) (*Account, error)
- func (as *AccountState) PutAccount(acc *Account) error
- func (as *AccountState) PutAccountAlias(alias string, addr common.Address) error
Constants ¶
View Source
const ( RecordsPrefix = "r_" // records CertReceivedPrefix = "cr_" // certs received CertIssuedPrefix = "ci_" // certs issued AliasKey = "alias" // alias key for data trie )
Prefixes for Account's Data trie
View Source
const ( AccountPrefix = "ac_" // alias account prefix for account state trie AliasAccountPrefix = "al_" // alias account prefix for account state trie )
Prefixes for blockState trie
View Source
const ( UnstakingWaitDuration = 7 * 24 * time.Hour PointsRegenerateDuration = 7 * 24 * time.Hour )
constants
Variables ¶
View Source
var ( ErrElapsedTimestamp = errors.New("cannot calculate points for elapsed timestamp") ErrNotFound = trie.ErrNotFound )
errors
Functions ¶
func KeyTrieToSlice ¶
KeyTrieToSlice generate slice from trie (slice of key)
Types ¶
type Account ¶
type Account struct { Address common.Address // address account key Balance *util.Uint128 // balance account's coin amount Nonce uint64 // nonce account sequential number Staking *util.Uint128 // account's staking amount Voted *trie.Batch // voted candidates key: candidateID, value: candidateID CandidateID []byte // Points *util.Uint128 LastPointsTs int64 Unstaking *util.Uint128 LastUnstakingTs int64 Data *trie.Batch // contain records, certReceived, certIssued Storage storage.Storage }
Account default item in state
func (*Account) VotedSlice ¶
VotedSlice returns slice converted from Voted trie
type AccountState ¶
AccountState is a struct for account state
func NewAccountState ¶
func NewAccountState(rootHash []byte, stor storage.Storage) (*AccountState, error)
NewAccountState returns new AccountState
func (*AccountState) Accounts ¶
func (as *AccountState) Accounts() ([]*Account, error)
Accounts returns account slice, except alias account
func (*AccountState) Clone ¶
func (as *AccountState) Clone() (*AccountState, error)
Clone clones state
func (*AccountState) DelAccountAlias ¶
func (as *AccountState) DelAccountAlias(alias string, addr common.Address) error
DelAccountAlias del alias name info
func (*AccountState) GetAccount ¶
GetAccount returns account
func (*AccountState) GetAccountByAlias ¶
func (as *AccountState) GetAccountByAlias(alias string, timestamp int64) (*Account, error)
GetAccountByAlias returns account by alias
func (*AccountState) PutAccount ¶
func (as *AccountState) PutAccount(acc *Account) error
PutAccount put account to trie batch
func (*AccountState) PutAccountAlias ¶
func (as *AccountState) PutAccountAlias(alias string, addr common.Address) error
PutAccountAlias put alias name for address
Click to show internal directories.
Click to hide internal directories.