mempool

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: Apache-2.0, BSD-2-Clause Imports: 27 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTransactionInvalid is returned if a Transaction is found to be invalid.
	ErrTransactionInvalid = errors.New("transaction invalid")

	// ErrTransactionUnsolid is returned if a Transaction consumes unsolid Outputs..
	ErrTransactionUnsolid = errors.New("transaction unsolid")
)
View Source
var NewEvents = event.CreateGroupConstructor(func() (newEvents *Events) {
	return &Events{
		TransactionStored:            event.New1[*TransactionStoredEvent](),
		TransactionBooked:            event.New1[*TransactionBookedEvent](),
		TransactionInclusionUpdated:  event.New1[*TransactionInclusionUpdatedEvent](),
		TransactionAccepted:          event.New1[*TransactionEvent](),
		TransactionOrphaned:          event.New1[*TransactionEvent](),
		TransactionRejected:          event.New1[*TransactionMetadata](),
		TransactionForked:            event.New1[*TransactionForkedEvent](),
		TransactionConflictIDUpdated: event.New1[*TransactionConflictIDUpdatedEvent](),
		TransactionInvalid:           event.New1[*TransactionInvalidEvent](),
		OutputCreated:                event.New1[utxo.OutputID](),
		OutputSpent:                  event.New1[utxo.OutputID](),
		OutputRejected:               event.New1[utxo.OutputID](),
		Error:                        event.New1[error](),

		ConflictDAG: conflictdag.NewEvents[utxo.TransactionID, utxo.OutputID](),
	}
})

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

Functions

This section is empty.

Types

type Consumer

type Consumer struct {
	model.StorableReferenceWithMetadata[Consumer, *Consumer, utxo.OutputID, utxo.TransactionID, consumer] `serix:"0"`
}

Consumer represents the reference between an Output and its spending Transaction.

func NewConsumer

func NewConsumer(consumedInput utxo.OutputID, transactionID utxo.TransactionID) *Consumer

NewConsumer return a new Consumer reference from the named Output to the named Transaction.

func (*Consumer) ConsumedInput

func (c *Consumer) ConsumedInput() (outputID utxo.OutputID)

ConsumedInput returns the identifier of the Output that was spent.

func (*Consumer) IsBooked

func (c *Consumer) IsBooked() bool

IsBooked returns a boolean flag that indicates whether the Consumer was completely booked.

func (*Consumer) SetBooked

func (c *Consumer) SetBooked() (updated bool)

SetBooked sets a boolean flag that indicates whether the Consumer was completely booked.

func (*Consumer) TransactionID

func (c *Consumer) TransactionID() (spendingTransaction utxo.TransactionID)

TransactionID returns the identifier of the spending Transaction.

type Events

type Events struct {
	// TransactionStored is an event that gets triggered whenever a new Transaction is stored.
	TransactionStored *event.Event1[*TransactionStoredEvent]

	// TransactionBooked is an event that gets triggered whenever a Transaction is booked.
	TransactionBooked *event.Event1[*TransactionBookedEvent]

	// TransactionInclusionUpdated is an event that gets triggered whenever the inclusion time of a Transaction changes.
	TransactionInclusionUpdated *event.Event1[*TransactionInclusionUpdatedEvent]

	// TransactionAccepted is an event that gets triggered whenever a Transaction is accepted.
	TransactionAccepted *event.Event1[*TransactionEvent]

	// TransactionOrphaned is an event that gets triggered whenever a Transaction is orphaned.
	TransactionOrphaned *event.Event1[*TransactionEvent]

	// TransactionRejected is an event that gets triggered whenever a Transaction is rejected.
	TransactionRejected *event.Event1[*TransactionMetadata]

	// TransactionForked is an event that gets triggered whenever a Transaction is forked.
	TransactionForked *event.Event1[*TransactionForkedEvent]

	// TransactionConflictIDUpdated is an event that gets triggered whenever the Conflict of a Transaction is updated.
	TransactionConflictIDUpdated *event.Event1[*TransactionConflictIDUpdatedEvent]

	// TransactionInvalid is an event that gets triggered whenever a Transaction is found to be invalid.
	TransactionInvalid *event.Event1[*TransactionInvalidEvent]

	OutputCreated  *event.Event1[utxo.OutputID]
	OutputSpent    *event.Event1[utxo.OutputID]
	OutputRejected *event.Event1[utxo.OutputID]

	// Error is event that gets triggered whenever an error occurs while processing a Transaction.
	Error *event.Event1[error]

	ConflictDAG *conflictdag.Events[utxo.TransactionID, utxo.OutputID]

	event.Group[Events, *Events]
}

Events is a container that acts as a dictionary for the existing events of a MemPool.

type MemPool

type MemPool interface {
	// Events is a dictionary for MemPool related events.
	Events() *Events

	// Storage provides access to the stored models inside the MemPool.
	Storage() Storage

	// Utils provides various helpers to access the MemPool.
	Utils() Utils

	// ConflictDAG is a reference to the ConflictDAG that is used by this MemPool.
	ConflictDAG() *conflictdag.ConflictDAG[utxo.TransactionID, utxo.OutputID]

	// StoreAndProcessTransaction stores and processes the given Transaction.
	StoreAndProcessTransaction(ctx context.Context, tx utxo.Transaction) (err error)

	// PruneTransaction removes a Transaction from the MemPool (e.g. after it was orphaned or found to be invalid). If the
	// pruneFutureCone flag is true, then we do not just remove the named Transaction but also its future cone.
	PruneTransaction(txID utxo.TransactionID, pruneFutureCone bool)

	// SetTransactionInclusionSlot sets the inclusion timestamp of a Transaction.
	SetTransactionInclusionSlot(id utxo.TransactionID, inclusionSlot slot.Index)

	// CheckTransaction checks the validity of a Transaction.
	CheckTransaction(ctx context.Context, tx utxo.Transaction) (err error)

	// VM is the vm used for transaction validation.
	VM() vm.VM

	// Shutdown should be called when the module is stopped.
	Shutdown()

	module.Interface
}

type OutputMetadata

type OutputMetadata struct {
	model.Storable[utxo.OutputID, OutputMetadata, *OutputMetadata, outputMetadata] `serix:"0"`
}

OutputMetadata represents a container for additional information about an Output.

func NewOutputMetadata

func NewOutputMetadata(outputID utxo.OutputID) (metadata *OutputMetadata)

NewOutputMetadata returns new OutputMetadata for the given OutputID.

func (*OutputMetadata) AccessManaPledgeID

func (o *OutputMetadata) AccessManaPledgeID() identity.ID

AccessManaPledgeID returns the identifier of the node that received the access mana pledge.

func (*OutputMetadata) ConfirmationState

func (o *OutputMetadata) ConfirmationState() confirmation.State

ConfirmationState returns the confirmation state of the Output.

func (*OutputMetadata) ConfirmationStateTime

func (o *OutputMetadata) ConfirmationStateTime() time.Time

ConfirmationStateTime returns the last time the ConfirmationState was updated.

func (*OutputMetadata) ConflictIDs

ConflictIDs returns the conflicting ConflictIDs that the Output depends on.

func (*OutputMetadata) ConsensusManaPledgeID

func (o *OutputMetadata) ConsensusManaPledgeID() identity.ID

ConsensusManaPledgeID returns the identifier of the node that received the consensus mana pledge.

func (*OutputMetadata) FirstConsumer

func (o *OutputMetadata) FirstConsumer() utxo.TransactionID

FirstConsumer returns the first Transaction that ever spent the Output.

func (*OutputMetadata) InclusionSlot

func (o *OutputMetadata) InclusionSlot() slot.Index

InclusionSlot returns the creation slot of the Output.

func (*OutputMetadata) IsSpent

func (o *OutputMetadata) IsSpent() bool

IsSpent returns true if the Output has been spent.

func (*OutputMetadata) RegisterBookedConsumer

func (o *OutputMetadata) RegisterBookedConsumer(consumer utxo.TransactionID) (isConflicting bool, consumerToFork utxo.TransactionID)

RegisterBookedConsumer registers a booked consumer and checks if it is conflicting with another consumer that wasn't forked, yet.

func (*OutputMetadata) SetAccessManaPledgeID

func (o *OutputMetadata) SetAccessManaPledgeID(id identity.ID) (updated bool)

SetAccessManaPledgeID sets the identifier of the node that received the access mana pledge.

func (*OutputMetadata) SetConfirmationState

func (o *OutputMetadata) SetConfirmationState(confirmationState confirmation.State) (modified bool)

SetConfirmationState sets the confirmation state of the Output.

func (*OutputMetadata) SetConflictIDs

func (o *OutputMetadata) SetConflictIDs(conflictIDs *advancedset.AdvancedSet[utxo.TransactionID]) (modified bool)

SetConflictIDs sets the conflicting ConflictIDs that this Transaction depends on.

func (*OutputMetadata) SetConsensusManaPledgeID

func (o *OutputMetadata) SetConsensusManaPledgeID(id identity.ID) (updated bool)

SetConsensusManaPledgeID sets the identifier of the node that received the consensus mana pledge.

func (*OutputMetadata) SetInclusionSlot

func (o *OutputMetadata) SetInclusionSlot(inclusionSlot slot.Index) (updated bool)

SetInclusionSlot sets the creation slot of the Output.

type OutputWithMetadata

type OutputWithMetadata struct {
	model.Storable[utxo.OutputID, OutputWithMetadata, *OutputWithMetadata, outputWithMetadataModel] `serix:"0"`
}

OutputWithMetadata represents an Output with its associated metadata fields that are needed for slot management.

func NewOutputWithMetadata

func NewOutputWithMetadata(index slot.Index, outputID utxo.OutputID, output utxo.Output, consensusManaPledgeID, accessManaPledgeID identity.ID) (o *OutputWithMetadata)

NewOutputWithMetadata returns a new OutputWithMetadata object.

func (*OutputWithMetadata) AccessManaPledgeID

func (o *OutputWithMetadata) AccessManaPledgeID() (consensusPledgeID identity.ID)

AccessManaPledgeID returns the access pledge id of the output.

func (*OutputWithMetadata) ConsensusManaPledgeID

func (o *OutputWithMetadata) ConsensusManaPledgeID() (consensusPledgeID identity.ID)

ConsensusManaPledgeID returns the consensus pledge id of the output.

func (*OutputWithMetadata) FromBytes

func (o *OutputWithMetadata) FromBytes(data []byte) (consumedBytes int, err error)

FromBytes unmarshals an OutputWithMetadata from a sequence of bytes.

func (*OutputWithMetadata) FromObjectStorage

func (o *OutputWithMetadata) FromObjectStorage(key, value []byte) error

FromObjectStorage creates an OutputWithMetadata from sequences of key and bytes.

func (*OutputWithMetadata) Index

func (o *OutputWithMetadata) Index() slot.Index

Index returns the index of the output.

func (*OutputWithMetadata) Output

func (o *OutputWithMetadata) Output() (output utxo.Output)

Output returns the Output field.

func (*OutputWithMetadata) SetAccessManaPledgeID

func (o *OutputWithMetadata) SetAccessManaPledgeID(accessPledgeID identity.ID)

SetAccessManaPledgeID sets the access pledge id of the output.

func (*OutputWithMetadata) SetConsensusManaPledgeID

func (o *OutputWithMetadata) SetConsensusManaPledgeID(consensusPledgeID identity.ID)

SetConsensusManaPledgeID sets the consensus pledge id of the output.

func (*OutputWithMetadata) SetIndex

func (o *OutputWithMetadata) SetIndex(index slot.Index)

SetIndex sets the index of the output.

func (*OutputWithMetadata) SetOutput

func (o *OutputWithMetadata) SetOutput(output utxo.Output)

SetOutput sets the Output field.

func (*OutputWithMetadata) SetSpentInSlot

func (o *OutputWithMetadata) SetSpentInSlot(index slot.Index)

SetSpentInSlot sets the index of the epoc the output was spent in.

func (*OutputWithMetadata) SpentInSlot

func (o *OutputWithMetadata) SpentInSlot() slot.Index

func (*OutputWithMetadata) String

func (o *OutputWithMetadata) String() string

String returns a human-readable version of the OutputWithMetadata.

func (*OutputWithMetadata) ZIPPBalance

func (o *OutputWithMetadata) ZIPPBalance() (balance uint64, exists bool)

ZIPPBalance returns the ZIPP balance of the Output. TODO: don't make the ledger depend on devnetvm

type OutputsMetadata

type OutputsMetadata struct {
	// OrderedMap is the underlying data structure that holds the OutputMetadata objects.
	orderedmap.OrderedMap[utxo.OutputID, *OutputMetadata] `serix:"0"`
}

OutputsMetadata represents a collection of OutputMetadata objects indexed by their OutputID.

func NewOutputsMetadata

func NewOutputsMetadata(outputsMetadata ...*OutputMetadata) (metadata *OutputsMetadata)

NewOutputsMetadata returns a new OutputMetadata collection with the given elements.

func (*OutputsMetadata) Add

func (o *OutputsMetadata) Add(output *OutputMetadata) (added bool)

Add adds the given OutputMetadata object to the collection.

func (*OutputsMetadata) ConflictIDs

ConflictIDs returns a union of all ConflictIDs of the contained OutputMetadata objects.

func (*OutputsMetadata) Filter

func (o *OutputsMetadata) Filter(predicate func(outputMetadata *OutputMetadata) bool) (filtered *OutputsMetadata)

func (*OutputsMetadata) ForEach

func (o *OutputsMetadata) ForEach(callback func(outputMetadata *OutputMetadata) error) (err error)

ForEach executes the callback for each element in the collection (it aborts if the callback returns an error).

func (*OutputsMetadata) Get

func (o *OutputsMetadata) Get(id utxo.OutputID) (outputMetadata *OutputMetadata, exists bool)

Get returns the OutputMetadata object for the given OutputID.

func (*OutputsMetadata) IDs

func (o *OutputsMetadata) IDs() (ids utxo.OutputIDs)

IDs returns the identifiers of the stored OutputMetadata objects.

func (*OutputsMetadata) String

func (o *OutputsMetadata) String() string

String returns a human-readable version of the OutputsMetadata.

type Storage

type Storage interface {
	// OutputStorage is an object storage used to persist Output objects.
	OutputStorage() *generic.ObjectStorage[utxo.Output]

	// OutputMetadataStorage is an object storage used to persist OutputMetadata objects.
	OutputMetadataStorage() *generic.ObjectStorage[*OutputMetadata]

	// CachedOutput retrieves the CachedObject representing the named Output. The optional computeIfAbsentCallback can be
	// used to dynamically Construct a non-existing Output.
	CachedOutput(outputID utxo.OutputID, computeIfAbsentCallback ...func(outputID utxo.OutputID) utxo.Output) (cachedOutput *generic.CachedObject[utxo.Output])

	// CachedOutputs retrieves the CachedObjects containing the named Outputs.
	CachedOutputs(outputIDs utxo.OutputIDs) (cachedOutputs generic.CachedObjects[utxo.Output])

	// CachedOutputMetadata retrieves the CachedObject representing the named OutputMetadata. The optional
	// computeIfAbsentCallback can be used to dynamically Construct a non-existing OutputMetadata.
	CachedOutputMetadata(outputID utxo.OutputID, computeIfAbsentCallback ...func(outputID utxo.OutputID) *OutputMetadata) (cachedOutputMetadata *generic.CachedObject[*OutputMetadata])

	// CachedOutputsMetadata retrieves the CachedObjects containing the named OutputMetadata.
	CachedOutputsMetadata(outputIDs utxo.OutputIDs) (cachedOutputsMetadata generic.CachedObjects[*OutputMetadata])

	// CachedTransaction retrieves the CachedObject representing the named Transaction. The optional computeIfAbsentCallback
	// can be used to dynamically Construct a non-existing Transaction.
	CachedTransaction(transactionID utxo.TransactionID, computeIfAbsentCallback ...func(transactionID utxo.TransactionID) utxo.Transaction) (cachedTransaction *generic.CachedObject[utxo.Transaction])

	// CachedTransactionMetadata retrieves the CachedObject representing the named TransactionMetadata. The optional
	// computeIfAbsentCallback can be used to dynamically Construct a non-existing TransactionMetadata.
	CachedTransactionMetadata(transactionID utxo.TransactionID, computeIfAbsentCallback ...func(transactionID utxo.TransactionID) *TransactionMetadata) (cachedTransactionMetadata *generic.CachedObject[*TransactionMetadata])

	// CachedConsumers retrieves the CachedObjects containing the named Consumers.
	CachedConsumers(outputID utxo.OutputID) (cachedConsumers generic.CachedObjects[*Consumer])

	ForEachOutputID(callback func(utxo.OutputID) bool)
}

type TestFramework

type TestFramework struct {
	// Instance contains a reference to the MemPool instance that the TestFramework is using.
	Instance MemPool

	ConflictDAG *conflictdag.TestFramework
	// contains filtered or unexported fields
}

TestFramework provides common testing functionality for the ledger package. As such, it helps to easily build an UTXO-DAG by specifying transactions outputs/inputs via aliases. It makes use of a simplified MockedVM, with MockedTransaction, MockedOutput and MockedInput.

func NewTestFramework

func NewTestFramework(test *testing.T, instance MemPool) *TestFramework

NewTestFramework creates a new instance of the TestFramework with one default output "Genesis" which has to be consumed by the first transaction.

func (*TestFramework) AllBooked

func (t *TestFramework) AllBooked(txAliases ...string) (allBooked bool)

AllBooked returns whether all given transactions are booked.

func (*TestFramework) AssertBooked

func (t *TestFramework) AssertBooked(expectedBookedMap map[string]bool)

AssertBooked asserts the booking status of all given transactions.

func (*TestFramework) AssertBranchConfirmationState

func (t *TestFramework) AssertBranchConfirmationState(txAlias string, validator func(state confirmation.State) bool)

AssertBranchConfirmationState asserts the confirmation state of the given branch.

func (*TestFramework) AssertConflictDAG

func (t *TestFramework) AssertConflictDAG(expectedParents map[string][]string)

AssertConflictDAG asserts the structure of the conflict DAG as specified in expectedParents. "conflict3": {"conflict1","conflict2"} asserts that "conflict3" should have "conflict1" and "conflict2" as parents. It also verifies the reverse mapping, that there is a child reference (conflictdag.ChildConflict) from "conflict1"->"conflict3" and "conflict2"->"conflict3".

func (*TestFramework) AssertConflictIDs

func (t *TestFramework) AssertConflictIDs(expectedConflicts map[string][]string)

AssertConflictIDs asserts that the given transactions and their outputs are booked into the specified conflicts.

func (*TestFramework) AssertConflicts

func (t *TestFramework) AssertConflicts(expectedConflictSetToConflictsAliases map[string][]string)

AssertConflicts asserts conflict membership from conflictID -> conflicts but also the reverse mapping conflict -> conflictIDs. expectedConflictAliases should be specified as "output.0": {"conflict1", "conflict2"}.

func (*TestFramework) AssertTransactionConfirmationState

func (t *TestFramework) AssertTransactionConfirmationState(txAlias string, validator func(state confirmation.State) bool)

AssertTransactionConfirmationState asserts the confirmation state of the given transaction.

func (*TestFramework) ConflictIDs

func (t *TestFramework) ConflictIDs(txAliases ...string) (conflictIDs *advancedset.AdvancedSet[utxo.TransactionID])

ConflictIDs gets all conflictdag.ConflictIDs given by txAliases. Panics if an alias doesn't exist.

func (*TestFramework) ConsumeOutput

func (t *TestFramework) ConsumeOutput(outputID utxo.OutputID, consumer func(output utxo.Output))

ConsumeOutput loads and consumes Output. Asserts that the loaded entity exists.

func (*TestFramework) ConsumeOutputMetadata

func (t *TestFramework) ConsumeOutputMetadata(outputID utxo.OutputID, consumer func(outputMetadata *OutputMetadata))

ConsumeOutputMetadata loads and consumes OutputMetadata. Asserts that the loaded entity exists.

func (*TestFramework) ConsumeTransactionMetadata

func (t *TestFramework) ConsumeTransactionMetadata(txID utxo.TransactionID, consumer func(txMetadata *TransactionMetadata))

ConsumeTransactionMetadata loads and consumes TransactionMetadata. Asserts that the loaded entity exists.

func (*TestFramework) ConsumeTransactionOutputs

func (t *TestFramework) ConsumeTransactionOutputs(mockTx *mockedvm.MockedTransaction, consumer func(outputMetadata *OutputMetadata))

ConsumeTransactionOutputs loads and consumes all OutputMetadata of the given Transaction. Asserts that the loaded entities exists.

func (*TestFramework) CreateTransaction

func (t *TestFramework) CreateTransaction(txAlias string, outputCount uint16, inputAliases ...string) (tx *mockedvm.MockedTransaction)

CreateTransaction creates a transaction with the given alias and outputCount. Inputs for the transaction are specified by their aliases where <txAlias.outputCount>. Panics if an input does not exist.

func (*TestFramework) IssueTransactions

func (t *TestFramework) IssueTransactions(txAliases ...string) (err error)

IssueTransactions issues the transaction given by txAlias.

func (*TestFramework) MockOutputFromTx

func (t *TestFramework) MockOutputFromTx(tx *mockedvm.MockedTransaction, outputIndex uint16) (mockedOutputID utxo.OutputID)

MockOutputFromTx creates an utxo.OutputID from a given MockedTransaction and outputIndex.

func (*TestFramework) OutputID

func (t *TestFramework) OutputID(alias string) (outputID utxo.OutputID)

OutputID gets the created utxo.OutputID by the given alias. Panics if it doesn't exist.

func (*TestFramework) Transaction

func (t *TestFramework) Transaction(txAlias string) (tx *mockedvm.MockedTransaction)

Transaction gets the created MockedTransaction by the given alias. Panics if it doesn't exist.

func (*TestFramework) TransactionIDs

func (t *TestFramework) TransactionIDs(txAliases ...string) (txIDs utxo.TransactionIDs)

TransactionIDs gets all MockedTransaction given by txAliases. Panics if an alias doesn't exist.

type TransactionBookedEvent

type TransactionBookedEvent struct {
	// TransactionID contains the identifier of the booked Transaction.
	TransactionID utxo.TransactionID

	// Outputs contains the set of Outputs that this Transaction created.
	Outputs *utxo.Outputs

	// Context contains a Context provided by the caller that triggered this event.
	Context context.Context
}

TransactionBookedEvent is a container that acts as a dictionary for the TransactionBooked event related parameters.

type TransactionConflictIDUpdatedEvent

type TransactionConflictIDUpdatedEvent struct {
	// TransactionID contains the identifier of the Transaction whose ConflictIDs were updated.
	TransactionID utxo.TransactionID

	// AddedConflictID contains the identifier of the Conflict that was added to the ConflictIDs of the Transaction.
	AddedConflictID utxo.TransactionID

	// RemovedConflictIDs contains the set of the ConflictIDs that were removed while updating the Transaction.
	RemovedConflictIDs *advancedset.AdvancedSet[utxo.TransactionID]

	// Context contains a Context provided by the caller that triggered this event.
	Context context.Context
}

TransactionConflictIDUpdatedEvent is a container that acts as a dictionary for the TransactionConflictIDUpdated event related parameters.

type TransactionEvent

type TransactionEvent struct {
	Metadata       *TransactionMetadata
	CreatedOutputs []*OutputWithMetadata
	SpentOutputs   []*OutputWithMetadata
}

type TransactionForkedEvent

type TransactionForkedEvent struct {
	// TransactionID contains the identifier of the forked Transaction.
	TransactionID utxo.TransactionID

	// ParentConflicts contains the set of ConflictIDs that form the parent Conflicts for the newly forked Transaction.
	ParentConflicts *advancedset.AdvancedSet[utxo.TransactionID]

	// Context contains a Context provided by the caller that triggered this event.
	Context context.Context
}

TransactionForkedEvent is a container that acts as a dictionary for the TransactionForked event related parameters.

type TransactionInclusionUpdatedEvent

type TransactionInclusionUpdatedEvent struct {
	// TransactionID contains the identifier of the booked Transaction.
	TransactionID utxo.TransactionID

	// TransactionMetadata contains the metadata of the Transaction.
	TransactionMetadata *TransactionMetadata

	// InclusionSlot contains the InclusionSlot after it was updated.
	InclusionSlot slot.Index

	// PreviousInclusionSlot contains the InclusionSlot before it was updated.
	PreviousInclusionSlot slot.Index
}

TransactionInclusionUpdatedEvent is a container that acts as a dictionary for the TransactionInclusionUpdated event related parameters.

type TransactionInvalidEvent

type TransactionInvalidEvent struct {
	// TransactionID contains the identifier of the Transaction that was found to be invalid.
	TransactionID utxo.TransactionID

	// Reason contains the error that caused the Transaction to be considered invalid.
	Reason error

	// Context contains a Context provided by the caller that triggered this event.
	Context context.Context
}

TransactionInvalidEvent is a container that acts as a dictionary for the TransactionInvalid event related parameters.

type TransactionMetadata

type TransactionMetadata struct {
	model.Storable[utxo.TransactionID, TransactionMetadata, *TransactionMetadata, transactionMetadata] `serix:"0"`
}

TransactionMetadata represents a container for additional information about a Transaction.

func NewTransactionMetadata

func NewTransactionMetadata(txID utxo.TransactionID) (metadata *TransactionMetadata)

NewTransactionMetadata returns new TransactionMetadata for the given TransactionID.

func (*TransactionMetadata) BookingTime

func (t *TransactionMetadata) BookingTime() time.Time

BookingTime returns the time when the Transaction was booked.

func (*TransactionMetadata) ConfirmationState

func (t *TransactionMetadata) ConfirmationState() confirmation.State

ConfirmationState returns the confirmation status of the Transaction.

func (*TransactionMetadata) ConfirmationStateTime

func (t *TransactionMetadata) ConfirmationStateTime() time.Time

ConfirmationStateTime returns the last time the ConfirmationState was updated.

func (*TransactionMetadata) ConflictIDs

ConflictIDs returns the conflicting ConflictIDs that the Transaction depends on.

func (*TransactionMetadata) InclusionSlot

func (t *TransactionMetadata) InclusionSlot() slot.Index

InclusionSlot returns the inclusion time of the Transaction.

func (*TransactionMetadata) IsBooked

func (t *TransactionMetadata) IsBooked() bool

IsBooked returns a boolean flag indicating whether the Transaction has been booked.

func (*TransactionMetadata) IsConflicting

func (t *TransactionMetadata) IsConflicting() bool

IsConflicting returns true if the Transaction is conflicting with another Transaction (is a Conflict).

func (*TransactionMetadata) OutputIDs

func (t *TransactionMetadata) OutputIDs() utxo.OutputIDs

OutputIDs returns the identifiers of the Outputs that the Transaction created.

func (*TransactionMetadata) SetBooked

func (t *TransactionMetadata) SetBooked(booked bool) (modified bool)

SetBooked sets a boolean flag indicating whether the Transaction has been booked.

func (*TransactionMetadata) SetConfirmationState

func (t *TransactionMetadata) SetConfirmationState(confirmationState confirmation.State) (modified bool)

SetConfirmationState sets the confirmation status of the Transaction.

func (*TransactionMetadata) SetConflictIDs

func (t *TransactionMetadata) SetConflictIDs(conflictIDs *advancedset.AdvancedSet[utxo.TransactionID]) (modified bool)

SetConflictIDs sets the conflicting ConflictIDs that this Transaction depends on.

func (*TransactionMetadata) SetInclusionSlot

func (t *TransactionMetadata) SetInclusionSlot(inclusionSlot slot.Index) (updated bool, previousInclusionSlot slot.Index)

SetInclusionSlot sets the inclusion time of the Transaction.

func (*TransactionMetadata) SetOutputIDs

func (t *TransactionMetadata) SetOutputIDs(outputIDs utxo.OutputIDs) (modified bool)

SetOutputIDs sets the identifiers of the Outputs that the Transaction created.

type TransactionStoredEvent

type TransactionStoredEvent struct {
	// TransactionID contains the identifier of the stored Transaction.
	TransactionID utxo.TransactionID
}

TransactionStoredEvent is a container that acts as a dictionary for the TransactionStored event related parameters.

type Utils

type Utils interface {
	// ResolveInputs returns the OutputIDs that were referenced by the given Inputs.
	ResolveInputs(inputs []utxo.Input) (outputIDs utxo.OutputIDs)

	ConflictIDsInFutureCone(conflictIDs utxo.TransactionIDs) (conflictIDsInFutureCone utxo.TransactionIDs)

	ReferencedTransactions(tx utxo.Transaction) (transactionIDs utxo.TransactionIDs)

	// TransactionConfirmationState returns the ConfirmationState of the Transaction with the given TransactionID.
	TransactionConfirmationState(txID utxo.TransactionID) (confirmationState confirmation.State)

	// WithTransactionAndMetadata walks over the transactions that consume the named OutputIDs and calls the callback
	// with their corresponding Transaction and TransactionMetadata.
	WithTransactionAndMetadata(txID utxo.TransactionID, callback func(tx utxo.Transaction, txMetadata *TransactionMetadata))

	// WalkConsumingTransactionID walks over the TransactionIDs that consume the named OutputIDs.
	WalkConsumingTransactionID(entryPoints utxo.OutputIDs, callback func(consumingTxID utxo.TransactionID, walker *walker.Walker[utxo.OutputID]))

	// WalkConsumingTransactionMetadata walks over the transactions that consume the named OutputIDs and calls the callback
	// with their corresponding TransactionMetadata.
	WalkConsumingTransactionMetadata(entryPoints utxo.OutputIDs, callback func(txMetadata *TransactionMetadata, walker *walker.Walker[utxo.OutputID]))

	ConfirmedConsumer(outputID utxo.OutputID) (consumerID utxo.TransactionID)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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