state

package
v0.14.7 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2021 License: AGPL-3.0 Imports: 13 Imported by: 14

Documentation

Index

Constants

View Source
const (
	KeyPartOwner      = uint16(0)
	KeyPartController = uint16(1)
	KeyPartKey        = uint16(2)
)

Variables

This section is empty.

Functions

func CommitDelta

func CommitDelta(ldg ledger.Ledger, delta delta.Delta, baseState flow.StateCommitment) (flow.StateCommitment, error)

func IsBlockExecuted added in v0.11.0

func IsBlockExecuted(ctx context.Context, state ReadOnlyExecutionState, block flow.Identifier) (bool, error)

IsBlockExecuted returns whether the block has been executed. it checks whether the state commitment exists in execution state.

func LedgerGetRegister

func LedgerGetRegister(ldg ledger.Ledger, commitment flow.StateCommitment) delta.GetRegisterFunc

func RegisterIDSToKeys added in v0.10.0

func RegisterIDSToKeys(ids []flow.RegisterID) []ledger.Key

func RegisterIDToKey added in v0.10.0

func RegisterIDToKey(reg flow.RegisterID) ledger.Key

func RegisterValuesToValues added in v0.10.0

func RegisterValuesToValues(values []flow.RegisterValue) []ledger.Value

Types

type ExecutionState

type ExecutionState interface {
	ReadOnlyExecutionState

	// CommitDelta commits a register delta and returns the new state commitment.
	CommitDelta(context.Context, delta.Delta, flow.StateCommitment) (flow.StateCommitment, error)

	// PersistStateCommitment saves a state commitment by the given block ID.
	PersistStateCommitment(context.Context, flow.Identifier, flow.StateCommitment) error

	// PersistChunkDataPack stores a chunk data pack by chunk ID.
	PersistChunkDataPack(context.Context, *flow.ChunkDataPack) error

	PersistExecutionResult(ctx context.Context, result *flow.ExecutionResult) error

	PersistExecutionReceipt(context.Context, *flow.ExecutionReceipt) error

	PersistStateInteractions(context.Context, flow.Identifier, []*delta.Snapshot) error

	UpdateHighestExecutedBlockIfHigher(context.Context, *flow.Header) error
}

ExecutionState is an interface used to access and mutate the execution state of the blockchain.

func NewExecutionState

func NewExecutionState(
	ls ledger.Ledger,
	commits storage.Commits,
	blocks storage.Blocks,
	collections storage.Collections,
	chunkDataPacks storage.ChunkDataPacks,
	results storage.ExecutionResults,
	receipts storage.ExecutionReceipts,
	db *badger.DB,
	tracer module.Tracer,
) ExecutionState

NewExecutionState returns a new execution state access layer for the given ledger storage.

type ReadOnlyExecutionState

type ReadOnlyExecutionState interface {
	// NewView creates a new ready-only view at the given state commitment.
	NewView(flow.StateCommitment) *delta.View

	GetRegisters(
		context.Context,
		flow.StateCommitment,
		[]flow.RegisterID,
	) ([]flow.RegisterValue, error)

	GetProof(
		context.Context,
		flow.StateCommitment,
		[]flow.RegisterID,
	) (flow.StorageProof, error)

	// StateCommitmentByBlockID returns the final state commitment for the provided block ID.
	StateCommitmentByBlockID(context.Context, flow.Identifier) (flow.StateCommitment, error)

	// ChunkDataPackByChunkID retrieve a chunk data pack given the chunk ID.
	ChunkDataPackByChunkID(context.Context, flow.Identifier) (*flow.ChunkDataPack, error)

	GetExecutionResultID(context.Context, flow.Identifier) (flow.Identifier, error)

	RetrieveStateDelta(context.Context, flow.Identifier) (*messages.ExecutionStateDelta, error)

	GetHighestExecutedBlockID(context.Context) (uint64, flow.Identifier, error)

	GetCollection(identifier flow.Identifier) (*flow.Collection, error)
}

ReadOnlyExecutionState allows to read the execution state

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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