iotex-core: github.com/iotexproject/iotex-core/state/factory Index | Files

package factory

import "github.com/iotexproject/iotex-core/state/factory"

Index

Package Files

factory.go statedb.go statetx.go workingset.go

Constants

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

type Factory Uses

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 Uses

func NewFactory(cfg config.Config, opts ...Option) (Factory, error)

NewFactory creates a new state factory

func NewStateDB Uses

func NewStateDB(cfg config.Config, opts ...StateDBOption) (Factory, error)

NewStateDB creates a new state db

type Option Uses

type Option func(*factory, config.Config) error

Option sets Factory construction parameter

func DefaultTrieOption Uses

func DefaultTrieOption() Option

DefaultTrieOption creates trie from config for state factory

func InMemTrieOption Uses

func InMemTrieOption() Option

InMemTrieOption creates in memory trie for state factory

func PrecreatedTrieDBOption Uses

func PrecreatedTrieDBOption(kv db.KVStore) Option

PrecreatedTrieDBOption uses pre-created trie DB for state factory

type StateDBOption Uses

type StateDBOption func(*stateDB, config.Config) error

StateDBOption sets stateDB construction parameter

func DefaultStateDBOption Uses

func DefaultStateDBOption() StateDBOption

DefaultStateDBOption creates default state db from config

func InMemStateDBOption Uses

func InMemStateDBOption() StateDBOption

InMemStateDBOption creates in memory state db

func PrecreatedStateDBOption Uses

func PrecreatedStateDBOption(kv db.KVStore) StateDBOption

PrecreatedStateDBOption uses pre-created state db

type WorkingSet Uses

type WorkingSet interface {
    // states and actions
    //RunActions(context.Context, uint64, []action.SealedEnvelope) (map[hash.Hash32B]*action.Receipt, error)
    RunAction(protocol.RunActionsCtx, 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 Uses

func NewWorkingSet(
    version uint64,
    kv db.KVStore,
    root hash.Hash256,
    actionHandlers []protocol.ActionHandler,
) (WorkingSet, error)

NewWorkingSet creates a new working set

Package factory imports 21 packages (graph) and is imported by 6 packages. Updated 2019-08-04. Refresh now. Tools for package owners.