engine

package
v1.0.0-beta.9 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSnapshottingInProgress = ierrors.New("snapshotting is already in progress")
)
View Source
var NewEvents = event.CreateGroupConstructor(func() (newEvents *Events) {
	return &Events{
		BlockProcessed:         event.New1[iotago.BlockID](),
		AcceptedBlockProcessed: event.New1[*blocks.Block](),
		Evict:                  event.New1[iotago.SlotIndex](),
		PreSolidFilter:         presolidfilter.NewEvents(),
		PostSolidFilter:        postsolidfilter.NewEvents(),
		BlockRequester:         eventticker.NewEvents[iotago.SlotIndex, iotago.BlockID](),
		TipManager:             tipmanager.NewEvents(),
		BlockDAG:               blockdag.NewEvents(),
		Booker:                 booker.NewEvents(),
		Clock:                  clock.NewEvents(),
		BlockGadget:            blockgadget.NewEvents(),
		SlotGadget:             slotgadget.NewEvents(),
		SybilProtection:        sybilprotection.NewEvents(),
		Ledger:                 ledger.NewEvents(),
		Notarization:           notarization.NewEvents(),
		SpendDAG:               spenddag.NewEvents[iotago.TransactionID, mempool.StateID](),
		Scheduler:              scheduler.NewEvents(),
		SeatManager:            seatmanager.NewEvents(),
		SyncManager:            syncmanager.NewEvents(),
		BlockRetainer:          retainer.NewBlockRetainerEvents(),
		TransactionRetainer:    retainer.NewTransactionRetainerEvents(),
	}
})

NewEvents contains the constructor of the Events object (it is generated by a generic factory).

Functions

func WithCommitmentCheck

func WithCommitmentCheck(checkCommitment bool) options.Option[Engine]

func WithEntryPointsDepth

func WithEntryPointsDepth(entryPointsDepth int) options.Option[Engine]

func WithSnapshotDepth

func WithSnapshotDepth(depth int) options.Option[Engine]

func WithSnapshotPath

func WithSnapshotPath(snapshotPath string) options.Option[Engine]

Types

type CommitmentAPI

type CommitmentAPI struct {

	// CommitmentID is the index of the slot that is accessed.
	CommitmentID iotago.CommitmentID
	// contains filtered or unexported fields
}

CommitmentAPI is a wrapper for the Engine that provides access to the data of a committed slot.

func NewCommitmentAPI

func NewCommitmentAPI(engine *Engine, commitmentID iotago.CommitmentID) *CommitmentAPI

NewCommitmentAPI creates a new CommitmentAPI.

func (*CommitmentAPI) Attestations

func (c *CommitmentAPI) Attestations() (commitment *model.Commitment, attestations []*iotago.Attestation, merkleProof *merklehasher.Proof[iotago.Identifier], err error)

Attestations returns the commitment, attestations and the merkle proof of the slot.

func (*CommitmentAPI) BlocksIDsBySlotCommitmentID

func (c *CommitmentAPI) BlocksIDsBySlotCommitmentID() (map[iotago.CommitmentID]iotago.BlockIDs, error)

BlocksIDsBySlotCommitmentID returns the accepted block IDs of the slot grouped by their SlotCommitmentID.

func (*CommitmentAPI) Commitment

func (c *CommitmentAPI) Commitment() (commitment *model.Commitment, err error)

Commitment returns the commitment of the slot.

func (*CommitmentAPI) Mutations

func (c *CommitmentAPI) Mutations() (acceptedBlocksBySlotCommitment map[iotago.CommitmentID]iotago.BlockIDs, acceptedBlocksProof *merklehasher.Proof[iotago.Identifier], acceptedTransactionIDs iotago.TransactionIDs, acceptedTransactionsProof *merklehasher.Proof[iotago.Identifier], err error)

Mutations returns all accepted block IDs, the tangle proof, all accepted transaction IDs and the ledger state mutation proof of the slot.

func (*CommitmentAPI) Roots

func (c *CommitmentAPI) Roots() (committedRoots *iotago.Roots, err error)

Roots returns the roots of the slot.

func (*CommitmentAPI) TransactionIDs

func (c *CommitmentAPI) TransactionIDs() (iotago.TransactionIDs, error)

type Engine

type Engine struct {
	Events              *Events
	Storage             *storage.Storage
	PreSolidFilter      presolidfilter.PreSolidFilter
	PostSolidFilter     postsolidfilter.PostSolidFilter
	EvictionState       *eviction.State
	BlockRequester      *eventticker.EventTicker[iotago.SlotIndex, iotago.BlockID]
	BlockDAG            blockdag.BlockDAG
	Booker              booker.Booker
	Clock               clock.Clock
	BlockGadget         blockgadget.Gadget
	SlotGadget          slotgadget.Gadget
	SybilProtection     sybilprotection.SybilProtection
	Notarization        notarization.Notarization
	SyncManager         syncmanager.SyncManager
	Attestations        attestation.Attestations
	Ledger              ledger.Ledger
	Scheduler           scheduler.Scheduler
	TipManager          tipmanager.TipManager
	TipSelection        tipselection.TipSelection
	BlockRetainer       retainer.BlockRetainer
	TxRetainer          retainer.TransactionRetainer
	UpgradeOrchestrator upgrade.Orchestrator

	// RootCommitment contains the earliest commitment that blocks we are solidifying will refer to, and is mainly
	// used to determine the cut-off point for the actively managed commitments in the protocol.
	RootCommitment reactive.Variable[*model.Commitment]

	// LatestCommitment contains the latest commitment that we have produced.
	LatestCommitment reactive.Variable[*model.Commitment]

	Workers *workerpool.Group

	BlockCache *blocks.Blocks

	module.Module
	// contains filtered or unexported fields
}

func New

func New(
	logger log.Logger,
	workers *workerpool.Group,
	storageInstance *storage.Storage,
	preSolidFilterProvider module.Provider[*Engine, presolidfilter.PreSolidFilter],
	postSolidFilterProvider module.Provider[*Engine, postsolidfilter.PostSolidFilter],
	blockDAGProvider module.Provider[*Engine, blockdag.BlockDAG],
	bookerProvider module.Provider[*Engine, booker.Booker],
	clockProvider module.Provider[*Engine, clock.Clock],
	blockGadgetProvider module.Provider[*Engine, blockgadget.Gadget],
	slotGadgetProvider module.Provider[*Engine, slotgadget.Gadget],
	sybilProtectionProvider module.Provider[*Engine, sybilprotection.SybilProtection],
	notarizationProvider module.Provider[*Engine, notarization.Notarization],
	syncManagerProvider module.Provider[*Engine, syncmanager.SyncManager],
	attestationProvider module.Provider[*Engine, attestation.Attestations],
	ledgerProvider module.Provider[*Engine, ledger.Ledger],
	schedulerProvider module.Provider[*Engine, scheduler.Scheduler],
	tipManagerProvider module.Provider[*Engine, tipmanager.TipManager],
	tipSelectionProvider module.Provider[*Engine, tipselection.TipSelection],
	blockRetainerProvider module.Provider[*Engine, retainer.BlockRetainer],
	txRetainerProvider module.Provider[*Engine, retainer.TransactionRetainer],
	upgradeOrchestratorProvider module.Provider[*Engine, upgrade.Orchestrator],
	opts ...options.Option[Engine],
) (engine *Engine)

func (*Engine) APIForEpoch

func (e *Engine) APIForEpoch(epoch iotago.EpochIndex) iotago.API

func (*Engine) APIForSlot

func (e *Engine) APIForSlot(slot iotago.SlotIndex) iotago.API

func (*Engine) APIForTime

func (e *Engine) APIForTime(t time.Time) iotago.API

func (*Engine) APIForVersion

func (e *Engine) APIForVersion(version iotago.Version) (iotago.API, error)

func (*Engine) Block

func (e *Engine) Block(id iotago.BlockID) (*model.Block, bool)

func (*Engine) BlockFromCache

func (e *Engine) BlockFromCache(id iotago.BlockID) (*blocks.Block, bool)

func (*Engine) ChainID

func (e *Engine) ChainID() iotago.CommitmentID

func (*Engine) CommitmentAPI

func (e *Engine) CommitmentAPI(commitmentID iotago.CommitmentID) (*CommitmentAPI, error)

CommitmentAPI returns the committed slot for the given slot index.

func (*Engine) CommittedAPI

func (e *Engine) CommittedAPI() iotago.API

func (*Engine) ErrorHandler

func (e *Engine) ErrorHandler(componentName string) func(error)

func (*Engine) Export

func (e *Engine) Export(writer io.WriteSeeker, targetSlot iotago.SlotIndex) (err error)

func (*Engine) ExportSnapshot

func (e *Engine) ExportSnapshot(filePath string, addSlotToFileName bool, useFinalized bool) (iotago.SlotIndex, string, error)

func (*Engine) ImportContents

func (e *Engine) ImportContents(reader io.ReadSeeker) (err error)

func (*Engine) ImportSettings

func (e *Engine) ImportSettings(reader io.ReadSeeker) (err error)

func (*Engine) Inspect

func (e *Engine) Inspect(session ...inspection.Session) inspection.InspectedObject

Inspect inspects the Engine and its subcomponents.

func (*Engine) IsSnapshotting

func (e *Engine) IsSnapshotting() bool

func (*Engine) LatestAPI

func (e *Engine) LatestAPI() iotago.API

func (*Engine) Name

func (e *Engine) Name() string

func (*Engine) ProcessBlockFromPeer

func (e *Engine) ProcessBlockFromPeer(block *model.Block, source peer.ID)

func (*Engine) RemoveFromFilesystem

func (e *Engine) RemoveFromFilesystem() error

RemoveFromFilesystem removes the directory of the engine from the filesystem.

func (*Engine) Reset

func (e *Engine) Reset()

Reset resets the component to a clean state as if it was created at the last commitment.

func (*Engine) SetChainID

func (e *Engine) SetChainID(chainID iotago.CommitmentID)

func (*Engine) WriteSnapshot

func (e *Engine) WriteSnapshot(filePath string, targetSlot ...iotago.SlotIndex) error

type Events

type Events struct {
	BlockProcessed         *event.Event1[iotago.BlockID]
	AcceptedBlockProcessed *event.Event1[*blocks.Block]
	Evict                  *event.Event1[iotago.SlotIndex]

	PreSolidFilter      *presolidfilter.Events
	PostSolidFilter     *postsolidfilter.Events
	BlockRequester      *eventticker.Events[iotago.SlotIndex, iotago.BlockID]
	TipManager          *tipmanager.Events
	BlockDAG            *blockdag.Events
	Booker              *booker.Events
	Clock               *clock.Events
	BlockGadget         *blockgadget.Events
	SlotGadget          *slotgadget.Events
	SybilProtection     *sybilprotection.Events
	Ledger              *ledger.Events
	Notarization        *notarization.Events
	SpendDAG            *spenddag.Events[iotago.TransactionID, mempool.StateID]
	Scheduler           *scheduler.Events
	SeatManager         *seatmanager.Events
	SyncManager         *syncmanager.Events
	BlockRetainer       *retainer.BlockRetainerEvents
	TransactionRetainer *retainer.TransactionRetainerEvents
	event.Group[Events, *Events]
}

Jump to

Keyboard shortcuts

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