factory

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: Apache-2.0 Imports: 34 Imported by: 4 modules, 18 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

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

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

NewMinter creates a wrapper instance

Types

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)
	PutBlock(context.Context, *block.Block) error
	DeleteTipBlock(*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

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

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

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

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

func PrecreatedTrieDBOption(kv db.KVStore) Option

PrecreatedTrieDBOption uses pre-created trie DB for state factory

func RegistryOption added in v1.0.0

func RegistryOption(reg *protocol.Registry) Option

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

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

StateDBOption sets stateDB construction parameter

func CachedStateDBOption added in v1.1.2

func CachedStateDBOption() StateDBOption

CachedStateDBOption creates state db with cache from config

func DefaultStateDBOption

func DefaultStateDBOption() StateDBOption

DefaultStateDBOption creates default state db from config

func InMemStateDBOption

func InMemStateDBOption() StateDBOption

InMemStateDBOption creates in memory state db

func PrecreatedStateDBOption added in v0.8.1

func PrecreatedStateDBOption(kv db.KVStore) StateDBOption

PrecreatedStateDBOption uses pre-created state db

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

Jump to

Keyboard shortcuts

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