mempool

package
v1.0.0-beta.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStateNotFound                    = ierrors.New("state not found")
	ErrInputSolidificationRequestFailed = ierrors.New("UTXO input solidification failed")
)

Functions

This section is empty.

Types

type CommitmentInputState

type CommitmentInputState struct {
	Commitment *iotago.Commitment
}

A thin wrapper around a resolved commitment.

func CommitmentInputStateFromCommitment

func CommitmentInputStateFromCommitment(commitment *iotago.Commitment) CommitmentInputState

func (CommitmentInputState) IsReadOnly

func (s CommitmentInputState) IsReadOnly() bool

func (CommitmentInputState) SlotBooked

func (s CommitmentInputState) SlotBooked() iotago.SlotIndex

func (CommitmentInputState) StateID

func (s CommitmentInputState) StateID() StateID

func (CommitmentInputState) Type

type CommitmentInputStateRef

type CommitmentInputStateRef struct {
	Input *iotago.CommitmentInput
}

A thin wrapper around a Commitment input.

func CommitmentInputStateRefFromInput

func CommitmentInputStateRefFromInput(input *iotago.CommitmentInput) CommitmentInputStateRef

func (CommitmentInputStateRef) ReferencedStateID

func (r CommitmentInputStateRef) ReferencedStateID() iotago.Identifier

func (CommitmentInputStateRef) Type

type MemPool

type MemPool[VoteRank spenddag.VoteRankType[VoteRank]] interface {
	AttachSignedTransaction(signedTransaction SignedTransaction, transaction Transaction, blockID iotago.BlockID) (signedTransactionMetadata SignedTransactionMetadata, err error)

	OnAttachTransactionFailed(callback func(transactionID iotago.TransactionID, blockID iotago.BlockID, err error), opts ...event.Option) *event.Hook[func(transactionID iotago.TransactionID, blockID iotago.BlockID, err error)]

	OnSignedTransactionAttached(callback func(signedTransactionMetadata SignedTransactionMetadata), opts ...event.Option) *event.Hook[func(metadata SignedTransactionMetadata)]

	OnTransactionAttached(callback func(metadata TransactionMetadata), opts ...event.Option) *event.Hook[func(metadata TransactionMetadata)]

	MarkAttachmentIncluded(blockID iotago.BlockID) bool

	StateMetadata(reference StateReference) (state StateMetadata, err error)

	TransactionMetadata(id iotago.TransactionID) (transaction TransactionMetadata, exists bool)

	VM() VM

	InjectRequestedState(state State)

	TransactionMetadataByAttachment(blockID iotago.BlockID) (transaction TransactionMetadata, exists bool)

	CommitStateDiff(slot iotago.SlotIndex) (StateDiff, error)

	Evict(slot iotago.SlotIndex)

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

type SignedTransaction

type SignedTransaction interface {
	// ID returns the identifier of the Transaction that contains a signature.
	ID() (iotago.SignedTransactionID, error)
	// MustID works like ID but panics if the SignedTransactionID can't be computed.
	MustID() iotago.SignedTransactionID
}

type SignedTransactionMetadata

type SignedTransactionMetadata interface {
	ID() iotago.SignedTransactionID

	SignedTransaction() SignedTransaction

	OnSignaturesValid(callback func()) (unsubscribe func())

	OnSignaturesInvalid(callback func(err error)) (unsubscribe func())

	SignaturesInvalid() error

	TransactionMetadata() TransactionMetadata

	Attachments() []iotago.BlockID
}

type State

type State interface {
	// The identifier of the state.
	StateID() StateID

	// The type of state.
	Type() StateType

	// Whether the state is read only.
	IsReadOnly() bool

	// SlotBooked returns the slot index of the state if it is booked.
	SlotBooked() iotago.SlotIndex
}

A generic interface over a state (like an output or a commitment).

type StateDiff

type StateDiff interface {
	// Slot returns the slot index of the state diff.
	Slot() iotago.SlotIndex

	// DestroyedStates returns a compacted list of all the states that were destroyed in the slot.
	DestroyedStates() *shrinkingmap.ShrinkingMap[StateID, StateMetadata]

	// CreatedStates returns a compacted list of all the states that were created in the slot.
	CreatedStates() *shrinkingmap.ShrinkingMap[StateID, StateMetadata]

	// ExecutedTransactions returns an un-compacted list of all the transactions that were executed in the slot.
	ExecutedTransactions() *orderedmap.OrderedMap[iotago.TransactionID, TransactionMetadata]

	// Mutations returns an authenticated data structure that allows to commit to the applied mutations.
	Mutations() ads.Set[iotago.Identifier, iotago.TransactionID]

	// Reset resets the component to a clean state as if it was created at the last commitment.
	Reset() error
}

StateDiff is a collection of changes that happened in a certain slot and that can be applied to the ledger state.

type StateID

type StateID = iotago.Identifier

type StateMetadata

type StateMetadata interface {
	State() State

	SpenderIDs() reactive.Set[iotago.TransactionID]

	PendingSpenderCount() int

	AcceptedSpender() (TransactionMetadata, bool)

	OnAcceptedSpenderUpdated(callback func(spender TransactionMetadata))

	InclusionSlot() iotago.SlotIndex

	OnInclusionSlotUpdated(callback func(prevSlot iotago.SlotIndex, newSlot iotago.SlotIndex))
	// contains filtered or unexported methods
}

type StateReference

type StateReference interface {
	// The identifier of the state to which it resolves.
	ReferencedStateID() iotago.Identifier

	// The type of state.
	Type() StateType
}

A reference to a state (like an output or a commitment).

type StateResolver

type StateResolver func(reference StateReference) *promise.Promise[State]

StateResolver is a function that resolves a StateReference to a Promise with the State.

type StateType

type StateType byte

StateType denotes the type of state.

const (
	StateTypeUTXOInput StateType = iota
	StateTypeCommitment
)

type Transaction

type Transaction interface {
	// ID returns the identifier of the Transaction.
	ID() (iotago.TransactionID, error)
	// MustID works like ID but panics if the TransactionID can't be computed.
	MustID() iotago.TransactionID
}

type TransactionMetadata

type TransactionMetadata interface {
	ID() iotago.TransactionID

	Transaction() Transaction

	Inputs() ds.Set[StateMetadata]

	Outputs() ds.Set[StateMetadata]

	SpenderIDs() reactive.Set[iotago.TransactionID]

	Commit()

	IsSolid() bool

	OnSolid(callback func())

	IsExecuted() bool

	OnExecuted(callback func())

	IsInvalid() bool

	OnInvalid(callback func(error))

	IsBooked() bool

	OnBooked(callback func())

	ValidAttachments() []iotago.BlockID

	EarliestIncludedAttachment() iotago.BlockID

	OnEarliestIncludedAttachmentUpdated(callback func(prevID, newID iotago.BlockID))

	OnEvicted(callback func())
	// contains filtered or unexported methods
}

type UTXOInputStateRef

type UTXOInputStateRef struct {
	Input *iotago.UTXOInput
}

A thin wrapper around a UTXO input.

func UTXOInputStateRefFromInput

func UTXOInputStateRefFromInput(input *iotago.UTXOInput) UTXOInputStateRef

func (UTXOInputStateRef) ReferencedStateID

func (r UTXOInputStateRef) ReferencedStateID() iotago.Identifier

func (UTXOInputStateRef) Type

func (r UTXOInputStateRef) Type() StateType

type VM

type VM interface {
	// Inputs returns the referenced inputs of the given transaction.
	Inputs(transaction Transaction) ([]StateReference, error)

	// ValidateSignatures validates the signatures of the given SignedTransaction and returns the execution context.
	ValidateSignatures(signedTransaction SignedTransaction, inputs []State) (executionContext context.Context, err error)

	// Execute executes the transaction in the given execution context and returns the resulting states.
	Execute(executionContext context.Context, transaction Transaction) (outputs []State, err error)
}

VM is the interface that defines the virtual machine that is used to validate and execute transactions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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