factory

package
v2.3.8 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AccountKVNamespace is the bucket name for account
	AccountKVNamespace = state.AccountKVNamespace
	// CurrentHeightKey indicates the key of current factory height in underlying DB
	CurrentHeightKey = "currentHeight"
)

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

	//DefaultConfig is the default config for state factory
	DefaultConfig = Config{
		Chain:   blockchain.DefaultConfig,
		Genesis: genesis.Default,
	}
)

Functions

func SetDiffCallback added in v2.3.7

func SetDiffCallback(f Factory, cb StateDiffCallback) bool

SetDiffCallback sets the state diff callback on a Factory. Returns false if the factory is not a stateDB (e.g., in-memory test factory).

Types

type Config

type Config struct {
	Chain   blockchain.Config
	Genesis genesis.Genesis
}

Config contains the config for factory

func GenerateConfig

func GenerateConfig(chain blockchain.Config, g genesis.Genesis) Config

GenerateConfig generates the factory config

type Factory

Factory defines an interface for managing states

func NewStateDB

func NewStateDB(cfg Config, dao db.KVStore, opts ...StateDBOption) (Factory, error)

NewStateDB creates a new state db

type MintOption added in v2.0.8

type MintOption func(*Minter)

MintOption defines an option to configure Minter

func WithTimeoutOption added in v2.0.8

func WithTimeoutOption(timeout time.Duration) MintOption

WithTimeoutOption sets the timeout for NewBlockBuilder

type Minter added in v2.2.0

type Minter struct {
	// contains filtered or unexported fields
}

Minter is a wrapper of Factory to mint blocks

func NewMinter

func NewMinter(f Factory, ap actpool.ActPool, opts ...MintOption) *Minter

NewMinter creates a wrapper instance

func (*Minter) Mint added in v2.2.0

func (m *Minter) Mint(ctx context.Context, pk crypto.PrivateKey) (*block.Block, error)

Mint creates a block with the given private key

func (*Minter) ReceiveBlock added in v2.2.0

func (m *Minter) ReceiveBlock(blk *block.Block) error

ReceiveBlock receives a confirmed block

type StateDBOption

type StateDBOption func(*stateDB, *Config) error

StateDBOption sets stateDB construction parameter

func DefaultPatchOption

func DefaultPatchOption() StateDBOption

DefaultPatchOption loads patchs

func DiffCallbackStateDBOption added in v2.3.7

func DiffCallbackStateDBOption(cb StateDiffCallback) StateDBOption

DiffCallbackStateDBOption sets a callback invoked after each block commit with the block's state diff entries. Used by ioSwarm for state diff streaming.

func DisableWorkingSetCacheOption

func DisableWorkingSetCacheOption() StateDBOption

DisableWorkingSetCacheOption disable workingset cache

func RegistryStateDBOption

func RegistryStateDBOption(reg *protocol.Registry) StateDBOption

RegistryStateDBOption sets the registry in state db

func SkipBlockValidationStateDBOption

func SkipBlockValidationStateDBOption() StateDBOption

SkipBlockValidationStateDBOption skips block validation on PutBlock

type StateDiffCallback added in v2.3.7

type StateDiffCallback func(height uint64, entries []WriteQueueEntry, digest []byte)

StateDiffCallback is called after a block is committed with the captured state diff entries.

type WorkingSetStoreFactory added in v2.2.0

type WorkingSetStoreFactory interface {
	CreateWorkingSetStore(context.Context, uint64, db.KVStore) (workingSetStore, error)
}

WorkingSetStoreFactory is the factory to create working set store

type WriteQueueEntry added in v2.3.7

type WriteQueueEntry struct {
	WriteType uint8 // 0=Put, 1=Delete
	Namespace string
	Key       []byte
	Value     []byte
}

WriteQueueEntry is a captured state mutation from the write queue.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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