corestate

package
v0.0.0-...-84d53aa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

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
	ErrUnauthorized     = errors.New("unauthorized request")
)

errors

Functions

func KeyTrieToSlice

func KeyTrieToSlice(trie *trie.Batch) [][]byte

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) FromBytes

func (acc *Account) FromBytes(b []byte) error

FromBytes returns Account form bytes

func (*Account) GetData

func (acc *Account) GetData(prefix string, key []byte) ([]byte, error)

GetData returns value in account's data trie

func (*Account) PutData

func (acc *Account) PutData(prefix string, key []byte, value []byte) error

PutData put value to account's data trie

func (*Account) ToBytes

func (acc *Account) ToBytes() ([]byte, error)

ToBytes convert account to bytes

func (*Account) VotedSlice

func (acc *Account) VotedSlice() ([][]byte, error)

VotedSlice returns slice converted from Voted trie

type AccountState

type AccountState struct {
	*trie.Batch
	// contains filtered or unexported fields
}

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

func (as *AccountState) GetAccount(addr common.Address, timestamp int64) (*Account, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL