statedifflength

package
v0.16.6 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package statedifflength backfills BlockCommitments.StateDiffLength for blocks stored before that field existed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Migrator

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

Migrator reads each block's state update, computes StateDiff.Length(), and rewrites the block's commitments with it. Pre-existing blocks stored 0 for the missing field, which this replaces with the real value.

Work is fanned out across reader goroutines that each fill their own write batch; a single committer drains them to disk. On a graceful shutdown the committed blocks form a contiguous range — the source emits in order and the pipeline drains everything it emitted — so the migration checkpoints the next block to resume from. After an error or crash it restarts from the oldest retained block, which is safe because re-deriving a length is idempotent.

func (*Migrator) Before

func (m *Migrator) Before(state []byte) error

Before restores the resume checkpoint from persisted intermediate state. A nil/empty state means a fresh run.

func (*Migrator) Migrate

func (m *Migrator) Migrate(
	ctx context.Context,
	database db.KeyValueStore,
	_ *networks.Network,
	logger log.StructuredLogger,
) ([]byte, error)

Jump to

Keyboard shortcuts

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