Documentation ¶
Index ¶
Constants ¶
const ( // AccountKVNamespace is the bucket name for account AccountKVNamespace = "Account" // ArchiveNamespacePrefix is the prefix of the buckets storing history data ArchiveNamespacePrefix = "Archive" // CurrentHeightKey indicates the key of current factory height in underlying DB CurrentHeightKey = "currentHeight" // ArchiveTrieNamespace is the bucket for the latest state view ArchiveTrieNamespace = "AccountTrie" // ArchiveTrieRootKey indicates the key of accountTrie root hash in underlying DB ArchiveTrieRootKey = "archiveTrieRoot" )
Variables ¶
var ( // ErrNotSupported is the error that the statedb is not for archive mode ErrNotSupported = errors.New("not supported") // ErrNoArchiveData is the error that the node have no archive data ErrNoArchiveData = errors.New("no archive data") //DefaultConfig is the default config for state factory DefaultConfig = Config{ Chain: blockchain.DefaultConfig, Genesis: genesis.Default, } )
Functions ¶
func NewHistoryStateReader ¶ added in v1.0.0
func NewHistoryStateReader(sf Factory, h uint64) protocol.StateReader
NewHistoryStateReader creates new history state reader by given state factory and height
func NewMinter ¶ added in v1.0.0
func NewMinter(f Factory, ap actpool.ActPool) blockchain.BlockBuilderFactory
NewMinter creates a wrapper instance
Types ¶
type Config ¶ added in v1.8.4
type Config struct { Chain blockchain.Config Genesis genesis.Genesis }
Config contains the config for factory
func GenerateConfig ¶ added in v1.8.4
func GenerateConfig(chain blockchain.Config, g genesis.Genesis) Config
GenerateConfig generates the factory config
type Factory ¶
type Factory interface { lifecycle.StartStopper protocol.StateReader Register(protocol.Protocol) error Validate(context.Context, *block.Block) error // NewBlockBuilder creates block builder NewBlockBuilder(context.Context, actpool.ActPool, func(action.Envelope) (action.SealedEnvelope, error)) (*block.Builder, error) SimulateExecution(context.Context, address.Address, *action.Execution, evm.GetBlockHash) ([]byte, *action.Receipt, error) ReadContractStorage(context.Context, address.Address, []byte) ([]byte, error) PutBlock(context.Context, *block.Block) error DeleteTipBlock(context.Context, *block.Block) error StateAtHeight(uint64, interface{}, ...protocol.StateOption) error StatesAtHeight(uint64, ...protocol.StateOption) (state.Iterator, error) }
Factory defines an interface for managing states
func NewFactory ¶
NewFactory creates a new state factory
func NewStateDB ¶
NewStateDB creates a new state db
type Option ¶
Option sets Factory construction parameter
func DefaultTriePatchOption ¶ added in v1.8.0
func DefaultTriePatchOption() Option
DefaultTriePatchOption loads patchs
func RegistryOption ¶ added in v1.0.0
RegistryOption sets the registry in state db
func SkipBlockValidationOption ¶ added in v1.1.0
func SkipBlockValidationOption() Option
SkipBlockValidationOption skips block validation on PutBlock
type StateDBOption ¶
StateDBOption sets stateDB construction parameter
func DefaultPatchOption ¶ added in v1.6.0
func DefaultPatchOption() StateDBOption
DefaultPatchOption loads patchs
func DisableWorkingSetCacheOption ¶ added in v1.8.4
func DisableWorkingSetCacheOption() StateDBOption
DisableWorkingSetCacheOption disable workingset cache
func RegistryStateDBOption ¶ added in v1.0.0
func RegistryStateDBOption(reg *protocol.Registry) StateDBOption
RegistryStateDBOption sets the registry in state db
func SkipBlockValidationStateDBOption ¶ added in v1.1.0
func SkipBlockValidationStateDBOption() StateDBOption
SkipBlockValidationStateDBOption skips block validation on PutBlock