Documentation ¶
Index ¶
Constants ¶
View Source
const ( // AccountKVNameSpace is the bucket name for account trie AccountKVNameSpace = "Account" // CandidateKVNameSpace is the bucket name for candidate data storage CandidateKVNameSpace = "Candidate" // CurrentHeightKey indicates the key of current factory height in underlying DB CurrentHeightKey = "currentHeight" // AccountTrieRootKey indicates the key of accountTrie root hash in underlying DB AccountTrieRootKey = "accountTrieRoot" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Factory ¶
type Factory interface { lifecycle.StartStopper // Accounts Balance(string) (*big.Int, error) Nonce(string) (uint64, error) // Note that Nonce starts with 1. AccountState(string) (*state.Account, error) RootHash() hash.Hash256 RootHashByHeight(uint64) (hash.Hash256, error) Height() (uint64, error) NewWorkingSet() (WorkingSet, error) Commit(WorkingSet) error // Candidate pool CandidatesByHeight(uint64) ([]*state.Candidate, error) State(hash.Hash160, interface{}) error AddActionHandlers(...protocol.ActionHandler) }
Factory defines an interface for managing states
func NewFactory ¶
NewFactory creates a new state factory
func NewStateDB ¶
func NewStateDB(cfg config.Config, opts ...StateDBOption) (Factory, error)
NewStateDB creates a new state db
type Option ¶
Option sets Factory construction parameter
func DefaultTrieOption ¶
func DefaultTrieOption() Option
DefaultTrieOption creates trie from config for state factory
func InMemTrieOption ¶
func InMemTrieOption() Option
InMemTrieOption creates in memory trie for state factory
func PrecreatedTrieDBOption ¶
PrecreatedTrieDBOption uses pre-created trie DB for state factory
type StateDBOption ¶
StateDBOption sets stateDB construction parameter
func DefaultStateDBOption ¶
func DefaultStateDBOption() StateDBOption
DefaultStateDBOption creates trie from config for state db
func InMemStateDBOption ¶
func InMemStateDBOption() StateDBOption
InMemStateDBOption creates in memory trie for state db
type WorkingSet ¶
type WorkingSet interface { // states and actions //RunActions(context.Context, uint64, []action.SealedEnvelope) (map[hash.Hash32B]*action.Receipt, error) RunAction(context.Context, action.SealedEnvelope) (*action.Receipt, error) UpdateBlockLevelInfo(blockHeight uint64) hash.Hash256 RunActions(context.Context, uint64, []action.SealedEnvelope) ([]*action.Receipt, error) Snapshot() int Revert(int) error Commit() error RootHash() hash.Hash256 Digest() hash.Hash256 Version() uint64 Height() uint64 // General state State(hash.Hash160, interface{}) error PutState(hash.Hash160, interface{}) error DelState(pkHash hash.Hash160) error GetDB() db.KVStore GetCachedBatch() db.CachedBatch }
WorkingSet defines an interface for working set of states changes
func NewWorkingSet ¶
func NewWorkingSet( version uint64, kv db.KVStore, root hash.Hash256, actionHandlers []protocol.ActionHandler, ) (WorkingSet, error)
NewWorkingSet creates a new working set
Click to show internal directories.
Click to hide internal directories.