statesync

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: GPL-3.0, LGPL-3.0 Imports: 29 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMainTrieTask added in v0.8.14

func NewMainTrieTask(sync *stateSync) syncTask

func NewStorageTrieTask added in v0.8.14

func NewStorageTrieTask(sync *stateSync, root common.Hash, accounts []common.Hash) syncTask

func NewSyncer added in v0.15.3

func NewSyncer(client syncclient.Client, db ethdb.Database, root common.Hash, codeQueue *CodeQueue, leafsRequestSize uint16, opts ...SyncerOption) (syncpkg.Syncer, error)

func NewTrieQueue added in v0.8.14

func NewTrieQueue(db ethdb.Database) *trieQueue

func NewTrieToSync added in v0.8.14

func NewTrieToSync(sync *stateSync, root common.Hash, account common.Hash, syncTask syncTask) (*trieToSync, error)

NewTrieToSync initializes a trieToSync and restores any previously started segments.

Types

type CodeQueue added in v0.15.4

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

CodeQueue implements the producer side of code fetching. It accepts code hashes, persists durable "to-fetch" markers (idempotent per hash), and enqueues the hashes as-is onto an internal channel consumed by the code syncer. The queue does not perform in-memory deduplication or local-code checks - that is the responsibility of the consumer.

func NewCodeQueue added in v0.15.4

func NewCodeQueue(db ethdb.Database, quit <-chan struct{}, opts ...CodeQueueOption) (*CodeQueue, error)

NewCodeQueue creates a new code queue applying optional functional options. The `quit` channel, if non-nil, MUST eventually be closed to avoid leaking a goroutine.

func (*CodeQueue) AddCode added in v0.15.4

func (q *CodeQueue) AddCode(codeHashes []common.Hash) error

AddCode persists and enqueues new code hashes. Persists idempotent "to-fetch" markers for all inputs and enqueues them as-is. Returns errAddCodeAfterFinalize after a clean finalize and errFailedToAddCodeHashesToQueue on early quit.

func (*CodeQueue) CodeHashes added in v0.15.4

func (q *CodeQueue) CodeHashes() <-chan common.Hash

CodeHashes returns the receive-only channel of code hashes to consume.

func (*CodeQueue) Finalize added in v0.15.4

func (q *CodeQueue) Finalize() error

Finalize signals that no further code hashes will be added. Waits for in-flight enqueues to complete, then closes the output channel. If the queue was already closed due to early quit, returns errFailedToFinalizeCodeQueue.

type CodeQueueOption added in v0.15.4

type CodeQueueOption = options.Option[CodeQueue]

func WithCapacity added in v0.15.4

func WithCapacity(n int) CodeQueueOption

WithCapacity overrides the queue buffer capacity.

type CodeSyncer added in v0.15.4

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

CodeSyncer syncs code bytes from the network in a separate thread. It consumes code hashes from a queue and persists code into the DB. Outstanding requests are tracked via durable "to-fetch" markers in the DB for recovery. The syncer performs in-flight deduplication and skips locally-present code before issuing requests.

func NewCodeSyncer added in v0.15.4

func NewCodeSyncer(client statesyncclient.Client, db ethdb.Database, codeHashes <-chan common.Hash, opts ...CodeSyncerOption) (*CodeSyncer, error)

NewCodeSyncer allows external packages (e.g., registry wiring) to create a code syncer that consumes hashes from a provided fetcher queue.

func (*CodeSyncer) ID added in v0.15.4

func (*CodeSyncer) ID() string

ID returns the stable identifier for this sync task.

func (*CodeSyncer) Name added in v0.15.4

func (*CodeSyncer) Name() string

Name returns the human-readable name for this sync task.

func (*CodeSyncer) Sync added in v0.15.4

func (c *CodeSyncer) Sync(ctx context.Context) error

Sync starts the worker thread and populates the code hashes queue with active work. Blocks until all outstanding code requests from a previous sync have been fetched and the code channel has been closed, or the context is cancelled.

type CodeSyncerOption added in v0.15.4

type CodeSyncerOption = options.Option[codeSyncerConfig]

CodeSyncerOption configures CodeSyncer at construction time.

func WithCodeHashesPerRequest added in v0.15.4

func WithCodeHashesPerRequest(n int) CodeSyncerOption

WithCodeHashesPerRequest sets the best-effort target batch size per request. The final batch may contain fewer than the configured number if insufficient hashes remain when the channel is closed.

func WithNumWorkers added in v0.15.4

func WithNumWorkers(n int) CodeSyncerOption

WithNumWorkers overrides the number of concurrent workers.

type SyncerOption added in v0.15.4

type SyncerOption = options.Option[stateSync]

SyncerOption configures the state syncer via functional options.

func WithBatchSize added in v0.15.4

func WithBatchSize(n uint) SyncerOption

WithBatchSize sets the database batch size for writes.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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