Documentation ¶
Index ¶
- Constants
- Variables
- func AlignedCoverages(vid1, vid2 *WrappedTx) (uint64, uint64)
- func IsPreferredMilestoneAgainstTheOther(vid1, vid2 *WrappedTx, preferYounger bool) bool
- func VerticesLines(vertices []*WrappedTx, prefix ...string) *lines.Lines
- func WrappedOutputsShortLines(wOuts []WrappedOutput) *lines.Lines
- type Flags
- type Status
- type TxIDStatus
- type TxIDStatusJSONAble
- type UnwrapOptions
- type UnwrapOptionsForTraverse
- type Vertex
- func (v *Vertex) ForEachEndorsement(fun func(i byte, vidEndorsed *WrappedTx) bool)
- func (v *Vertex) ForEachInputDependency(fun func(i byte, vidInput *WrappedTx) bool)
- func (v *Vertex) GetConsumedOutput(i byte) (ret *ledger.Output)
- func (v *Vertex) InputLoaderByIndex(i byte) (*ledger.Output, error)
- func (v *Vertex) Lines(prefix ...string) *lines.Lines
- func (v *Vertex) MissingInputTxIDSet() set.Set[ledger.TransactionID]
- func (v *Vertex) MissingInputTxIDString() string
- func (v *Vertex) NumMissingInputs() (missingInputs int, missingEndorsements int)
- func (v *Vertex) ReferenceEndorsement(i byte, vid *WrappedTx) bool
- func (v *Vertex) ReferenceInput(i byte, vid *WrappedTx) bool
- func (v *Vertex) SequencerInputIndex() byte
- func (v *Vertex) SetOfInputTransactions() set.Set[*WrappedTx]
- func (v *Vertex) StemInputIndex() byte
- func (v *Vertex) TimeSlot() ledger.Slot
- func (v *Vertex) UnReferenceDependencies()
- func (v *Vertex) ValidateConstraints(traceOption ...int) error
- func (v *Vertex) Wrap() *WrappedTx
- type VirtualTransaction
- func (v *VirtualTransaction) OutputAt(idx byte) (*ledger.Output, bool)
- func (v *VirtualTransaction) PullNeeded() bool
- func (v *VirtualTransaction) PullPatienceExpired(maxPullAttempts int) bool
- func (v *VirtualTransaction) PullRulesDefined() bool
- func (v *VirtualTransaction) SequencerOutputs() (*ledger.Output, *ledger.Output)
- func (v *VirtualTransaction) SetPullHappened(nTimes int, repeatAfter time.Duration)
- func (v *VirtualTransaction) SetPullNeeded()
- func (v *VirtualTransaction) SetPullNotNeeded()
- type WrappedOutput
- type WrappedTx
- func (vid *WrappedTx) AttachConsumer(outputIndex byte, consumer *WrappedTx, ...) (conflict *WrappedTx)
- func (vid *WrappedTx) BaselineBranch() (baselineBranch *WrappedTx)
- func (vid *WrappedTx) ConsumersOf(outIdx byte) set.Set[*WrappedTx]
- func (vid *WrappedTx) ConvertVertexToVirtualTx()
- func (vid *WrappedTx) ConvertVirtualTxToVertexNoLock(v *Vertex)
- func (vid *WrappedTx) DoPruningIfRelevant(nowis time.Time) (markedForDeletion, unreferencedPastCone bool, references uint32)
- func (vid *WrappedTx) EnsureOutputWithID(o *ledger.OutputWithID) (err error)
- func (vid *WrappedTx) FindChainOutput(chainID *ledger.ChainID) (ret *ledger.OutputWithID)
- func (vid *WrappedTx) FlagsNoLock() Flags
- func (vid *WrappedTx) FlagsUp(f Flags) bool
- func (vid *WrappedTx) FlagsUpNoLock(f Flags) bool
- func (vid *WrappedTx) GetAttachmentDepthNoLock() int
- func (vid *WrappedTx) GetError() error
- func (vid *WrappedTx) GetErrorNoLock() error
- func (vid *WrappedTx) GetLedgerCoverage() uint64
- func (vid *WrappedTx) GetLedgerCoverageNoLock() *uint64
- func (vid *WrappedTx) GetLedgerCoverageP() *uint64
- func (vid *WrappedTx) GetLedgerCoverageString() string
- func (vid *WrappedTx) GetTxStatus() Status
- func (vid *WrappedTx) GetTxStatusNoLock() Status
- func (vid *WrappedTx) IDShortString() string
- func (vid *WrappedTx) IDVeryShort() string
- func (vid *WrappedTx) InflationAmountOfSequencerMilestone() (ret uint64)
- func (vid *WrappedTx) InflationConstraintOnSequencerOutput() (ret *ledger.InflationConstraint)
- func (vid *WrappedTx) IsBadOrDeleted() bool
- func (vid *WrappedTx) IsBranchTransaction() bool
- func (vid *WrappedTx) IsSequencerMilestone() bool
- func (vid *WrappedTx) IsVirtualTx() (ret bool)
- func (vid *WrappedTx) Lines(prefix ...string) *lines.Lines
- func (vid *WrappedTx) LinesNoLock(prefix ...string) *lines.Lines
- func (vid *WrappedTx) LinesTx(prefix ...string) *lines.Lines
- func (vid *WrappedTx) MustOutputAt(idx byte) *ledger.Output
- func (vid *WrappedTx) MustOutputWithIDAt(idx byte) (ret ledger.OutputWithID)
- func (vid *WrappedTx) MustReference()
- func (vid *WrappedTx) MustSequencerIDAndStemID() (seqID ledger.ChainID, stemID ledger.OutputID)
- func (vid *WrappedTx) NotConsumedOutputIndices(allConsumers set.Set[*WrappedTx]) []byte
- func (vid *WrappedTx) NumConsumers() (int, int)
- func (vid *WrappedTx) NumInputs() int
- func (vid *WrappedTx) NumProducedOutputs() int
- func (vid *WrappedTx) NumReferences() int
- func (vid *WrappedTx) OnPoke(fun func())
- func (vid *WrappedTx) OutputAt(idx byte) (*ledger.Output, error)
- func (vid *WrappedTx) OutputID(idx byte) (ret ledger.OutputID)
- func (vid *WrappedTx) OutputWithIDAt(idx byte) (ledger.OutputWithID, error)
- func (vid *WrappedTx) PanicAccessDeleted()
- func (vid *WrappedTx) Poke()
- func (vid *WrappedTx) RUnwrap(opt UnwrapOptions)
- func (vid *WrappedTx) Reference() bool
- func (vid *WrappedTx) SequencerIDStringVeryShort() string
- func (vid *WrappedTx) SequencerPredecessor() (ret *WrappedTx)
- func (vid *WrappedTx) SequencerWrappedOutput() (ret WrappedOutput)
- func (vid *WrappedTx) SetAttachmentDepthNoLock(depth int)
- func (vid *WrappedTx) SetFlagsUpNoLock(f Flags)
- func (vid *WrappedTx) SetLedgerCoverage(coverage uint64)
- func (vid *WrappedTx) SetSequencerAttachmentFinished()
- func (vid *WrappedTx) SetTxStatusBad(reason error)
- func (vid *WrappedTx) SetTxStatusBadNoLock(reason error)
- func (vid *WrappedTx) SetTxStatusGood()
- func (vid *WrappedTx) ShortString() string
- func (vid *WrappedTx) Slot() ledger.Slot
- func (vid *WrappedTx) StemWrappedOutput() (ret WrappedOutput)
- func (vid *WrappedTx) String() (ret string)
- func (vid *WrappedTx) StringNoLock() string
- func (vid *WrappedTx) Timestamp() ledger.Time
- func (vid *WrappedTx) TraversePastConeDepthFirst(opt UnwrapOptionsForTraverse, visited ...set.Set[*WrappedTx])
- func (vid *WrappedTx) UnReference()
- func (vid *WrappedTx) Unwrap(opt UnwrapOptions)
- func (vid *WrappedTx) UnwrapVirtualTx(unwrapFun func(v *VirtualTransaction))
- func (vid *WrappedTx) WrappedInputs() (ret []WrappedOutput)
Constants ¶
const ( FlagVertexDefined = Flags(0b00000001) FlagVertexConstraintsValid = Flags(0b00000010) FlagVertexTxAttachmentStarted = Flags(0b00000100) FlagVertexTxAttachmentFinished = Flags(0b00001000) )
const ( Undefined = Status(iota) Good Bad )
Variables ¶
var ErrDeletedVertexAccessed = errors.New("deleted vertex should not be accessed")
ErrDeletedVertexAccessed exception is raised by PanicAccessDeleted handler of RUnwrap vertex so that could be caught if necessary
Functions ¶
func AlignedCoverages ¶
AlignedCoverages shifts one of coverages, if necessary, so that to make them comparable
func IsPreferredMilestoneAgainstTheOther ¶
IsPreferredMilestoneAgainstTheOther returns if vid1 is strongly better than vid2 'better' means aligned coverage is bigger, or, if equal, transaction ID is smaller
func WrappedOutputsShortLines ¶
func WrappedOutputsShortLines(wOuts []WrappedOutput) *lines.Lines
Types ¶
type TxIDStatus ¶
type TxIDStatus struct { ID ledger.TransactionID OnDAG bool InStorage bool VirtualTx bool Deleted bool Status Status Flags Flags Coverage *uint64 Err error }
func (*TxIDStatus) JSONAble ¶
func (s *TxIDStatus) JSONAble() (ret TxIDStatusJSONAble)
type TxIDStatusJSONAble ¶
type TxIDStatusJSONAble struct { ID string `json:"id"` OnDAG bool `json:"on_dag"` InStorage bool `json:"in_storage"` VirtualTx bool `json:"virtual_tx"` Deleted bool `json:"deleted"` Status string `json:"status"` Flags byte `json:"flags"` Coverage uint64 `json:"coverage,omitempty"` Err error `json:"err"` }
func (*TxIDStatusJSONAble) Parse ¶
func (s *TxIDStatusJSONAble) Parse() (*TxIDStatus, error)
type UnwrapOptions ¶
type UnwrapOptions struct { Vertex func(v *Vertex) VirtualTx func(v *VirtualTransaction) Deleted func() }
type UnwrapOptionsForTraverse ¶
type UnwrapOptionsForTraverse struct { Vertex func(vidCur *WrappedTx, v *Vertex) bool VirtualTx func(vidCur *WrappedTx, v *VirtualTransaction) bool TxID func(txid *ledger.TransactionID) Deleted func(vidCur *WrappedTx) bool }
type Vertex ¶
type Vertex struct { Tx *transaction.Transaction Inputs []*WrappedTx Endorsements []*WrappedTx BaselineBranch *WrappedTx }
Vertex is a transaction with past cone dependencies
func New ¶
func New(tx *transaction.Transaction) *Vertex
func (*Vertex) ForEachEndorsement ¶
func (*Vertex) ForEachInputDependency ¶
func (*Vertex) GetConsumedOutput ¶
GetConsumedOutput return produced output, is available. Returns nil if unavailable for any reason
func (*Vertex) InputLoaderByIndex ¶
InputLoaderByIndex returns consumed output at index i or nil (if input is orphaned or inaccessible in the virtualTx)
func (*Vertex) MissingInputTxIDSet ¶
func (v *Vertex) MissingInputTxIDSet() set.Set[ledger.TransactionID]
MissingInputTxIDSet returns set of txids for the missing inputs and endorsements
func (*Vertex) MissingInputTxIDString ¶
func (*Vertex) NumMissingInputs ¶
func (*Vertex) ReferenceEndorsement ¶
func (*Vertex) ReferenceInput ¶
ReferenceInput puts new input and references it. If referencing fails, no change happens and returns false
func (*Vertex) SequencerInputIndex ¶
func (*Vertex) SetOfInputTransactions ¶
func (*Vertex) StemInputIndex ¶
func (*Vertex) UnReferenceDependencies ¶
func (v *Vertex) UnReferenceDependencies()
UnReferenceDependencies un-references all not nil inputs and endorsements and invalidates vertex structure
func (*Vertex) ValidateConstraints ¶
ValidateConstraints creates full transaction context from the (solid) vertex data and runs validation of all constraints in the context
type VirtualTransaction ¶
VirtualTransaction is a collection of produced outputs
func VirtualTxFromTx ¶
func VirtualTxFromTx(tx *transaction.Transaction) *VirtualTransaction
VirtualTxFromTx converts transaction to a collection of produced outputs
func (*VirtualTransaction) OutputAt ¶
func (v *VirtualTransaction) OutputAt(idx byte) (*ledger.Output, bool)
OutputAt return output at the index and true, or nil, false if output is not available in the virtual tx
func (*VirtualTransaction) PullNeeded ¶
func (v *VirtualTransaction) PullNeeded() bool
func (*VirtualTransaction) PullPatienceExpired ¶
func (v *VirtualTransaction) PullPatienceExpired(maxPullAttempts int) bool
func (*VirtualTransaction) PullRulesDefined ¶
func (v *VirtualTransaction) PullRulesDefined() bool
func (*VirtualTransaction) SequencerOutputs ¶
func (v *VirtualTransaction) SequencerOutputs() (*ledger.Output, *ledger.Output)
SequencerOutputs returns <seq output>, <stem output> or respective nils
func (*VirtualTransaction) SetPullHappened ¶
func (v *VirtualTransaction) SetPullHappened(nTimes int, repeatAfter time.Duration)
SetPullHappened increases pull counter and sets nex pull deadline
func (*VirtualTransaction) SetPullNeeded ¶
func (v *VirtualTransaction) SetPullNeeded()
func (*VirtualTransaction) SetPullNotNeeded ¶
func (v *VirtualTransaction) SetPullNotNeeded()
type WrappedOutput ¶
func (*WrappedOutput) DecodeID ¶
func (o *WrappedOutput) DecodeID() *ledger.OutputID
func (*WrappedOutput) IDShortString ¶
func (o *WrappedOutput) IDShortString() string
func (*WrappedOutput) IsAvailable ¶
func (o *WrappedOutput) IsAvailable() (available bool)
func (*WrappedOutput) Slot ¶
func (o *WrappedOutput) Slot() ledger.Slot
func (*WrappedOutput) Timestamp ¶
func (o *WrappedOutput) Timestamp() ledger.Time
type WrappedTx ¶
type WrappedTx struct { // immutable ID. It does not change with the change of the underlying wrapped vertex type ID ledger.TransactionID // sequencer ID not nil for sequencer transactions only. Once it is set not nil, it is immutable since. // It is set whenever transaction becomes available SequencerID atomic.Pointer[ledger.ChainID] // contains filtered or unexported fields }
WrappedTx value of *WrappedTx is used as transaction identity on the UTXO tangle, a vertex Behind this identity can be wrapped usual vertex or virtual transactions
func WrapBranchDataAsVirtualTx ¶
func WrapBranchDataAsVirtualTx(branchData *multistate.BranchData) *WrappedTx
func WrapTxID ¶
func WrapTxID(txid ledger.TransactionID) *WrappedTx
WrapTxID creates VID with virtualTx which only contains txid. Also sets solidification deadline, after which IsPullDeadlineDue will start returning true The pull deadline will be dropped after transaction will become available and virtualTx will be converted to full vertex
func (*WrappedTx) AttachConsumer ¶
func (vid *WrappedTx) AttachConsumer(outputIndex byte, consumer *WrappedTx, checkConflicts func(existingConsumers set.Set[*WrappedTx]) (conflict *WrappedTx)) (conflict *WrappedTx)
AttachConsumer stores consumer of the vid[outputIndex] consumed output. Function checkConflicts checks if new consumer conflicts with already existing ones
func (*WrappedTx) BaselineBranch ¶
BaselineBranch baseline branch of the vertex Will return nil for virtual transaction
func (*WrappedTx) ConvertVertexToVirtualTx ¶
func (vid *WrappedTx) ConvertVertexToVirtualTx()
ConvertVertexToVirtualTx detaches past cone and leaves only a collection of produced outputs
func (*WrappedTx) ConvertVirtualTxToVertexNoLock ¶
func (*WrappedTx) DoPruningIfRelevant ¶
func (vid *WrappedTx) DoPruningIfRelevant(nowis time.Time) (markedForDeletion, unreferencedPastCone bool, references uint32)
DoPruningIfRelevant either marks vertex deleted (counter = 0), or, if it already deleted (counter=0) with TTL matured, un-references its past cone this way helping to prune other older vertices This trick is necessary in order to avoid deadlock between global state of the memeDAG and the local state of the wrappedTx. When trying to modify both atomically will lead to deadlock
func (*WrappedTx) EnsureOutputWithID ¶
func (vid *WrappedTx) EnsureOutputWithID(o *ledger.OutputWithID) (err error)
func (*WrappedTx) FindChainOutput ¶
func (vid *WrappedTx) FindChainOutput(chainID *ledger.ChainID) (ret *ledger.OutputWithID)
func (*WrappedTx) FlagsNoLock ¶
func (*WrappedTx) FlagsUpNoLock ¶
func (*WrappedTx) GetAttachmentDepthNoLock ¶
func (*WrappedTx) GetErrorNoLock ¶
func (*WrappedTx) GetLedgerCoverage ¶
func (*WrappedTx) GetLedgerCoverageNoLock ¶
func (*WrappedTx) GetLedgerCoverageP ¶
func (*WrappedTx) GetLedgerCoverageString ¶
func (*WrappedTx) GetTxStatus ¶
func (*WrappedTx) GetTxStatusNoLock ¶
func (*WrappedTx) IDShortString ¶
func (*WrappedTx) IDVeryShort ¶
func (*WrappedTx) InflationAmountOfSequencerMilestone ¶
func (*WrappedTx) InflationConstraintOnSequencerOutput ¶
func (vid *WrappedTx) InflationConstraintOnSequencerOutput() (ret *ledger.InflationConstraint)
func (*WrappedTx) IsBadOrDeleted ¶
IsBadOrDeleted non-deterministic
func (*WrappedTx) IsBranchTransaction ¶
func (*WrappedTx) IsSequencerMilestone ¶
func (*WrappedTx) IsVirtualTx ¶
func (*WrappedTx) MustOutputWithIDAt ¶
func (vid *WrappedTx) MustOutputWithIDAt(idx byte) (ret ledger.OutputWithID)
func (*WrappedTx) MustReference ¶
func (vid *WrappedTx) MustReference()
func (*WrappedTx) MustSequencerIDAndStemID ¶
func (*WrappedTx) NotConsumedOutputIndices ¶
func (*WrappedTx) NumConsumers ¶
NumConsumers returns: - number of consumed outputs - number of conflict sets
func (*WrappedTx) NumProducedOutputs ¶
func (*WrappedTx) NumReferences ¶
func (*WrappedTx) OutputAt ¶
OutputAt return output at index, if available. err != nil indicates wrong index nil, nil means output not available, but no error (orphaned)
func (*WrappedTx) OutputWithIDAt ¶
func (vid *WrappedTx) OutputWithIDAt(idx byte) (ledger.OutputWithID, error)
func (*WrappedTx) PanicAccessDeleted ¶
func (vid *WrappedTx) PanicAccessDeleted()
func (*WrappedTx) RUnwrap ¶
func (vid *WrappedTx) RUnwrap(opt UnwrapOptions)
func (*WrappedTx) Reference ¶
Reference increments reference counter for the vertex which is not deleted yet (counter > 0). It also sets TTL for vertex if it has noo references (counter == 1)
func (*WrappedTx) SequencerIDStringVeryShort ¶
func (*WrappedTx) SequencerPredecessor ¶
func (*WrappedTx) SequencerWrappedOutput ¶
func (vid *WrappedTx) SequencerWrappedOutput() (ret WrappedOutput)
func (*WrappedTx) SetAttachmentDepthNoLock ¶
func (*WrappedTx) SetFlagsUpNoLock ¶
func (*WrappedTx) SetLedgerCoverage ¶
func (*WrappedTx) SetSequencerAttachmentFinished ¶
func (vid *WrappedTx) SetSequencerAttachmentFinished()
func (*WrappedTx) SetTxStatusBad ¶
func (*WrappedTx) SetTxStatusBadNoLock ¶
func (*WrappedTx) SetTxStatusGood ¶
func (vid *WrappedTx) SetTxStatusGood()
func (*WrappedTx) ShortString ¶
func (*WrappedTx) StemWrappedOutput ¶
func (vid *WrappedTx) StemWrappedOutput() (ret WrappedOutput)
func (*WrappedTx) StringNoLock ¶
func (*WrappedTx) TraversePastConeDepthFirst ¶
func (vid *WrappedTx) TraversePastConeDepthFirst(opt UnwrapOptionsForTraverse, visited ...set.Set[*WrappedTx])
TraversePastConeDepthFirst performs depth-first traverse of the MemDAG. Visiting once each node and calling vertex-type specific function if provided on each. If function returns false, the traverse is cancelled globally. The traverse stops at terminal dag. The vertex is terminal if it either is not-full vertex i.e. (booked, orphaned, deleted) or it belongs to 'visited' set If 'visited' set is provided at call, it is mutable. In the end it contains all initial dag plus all dag visited during the traverse
func (*WrappedTx) UnReference ¶
func (vid *WrappedTx) UnReference()
UnReference decrements reference counter down to 1. It panics if counter value 1 is decremented because the value 0 is reserved for the deleted vertices (handled by DoPruningIfRelevant)
func (*WrappedTx) Unwrap ¶
func (vid *WrappedTx) Unwrap(opt UnwrapOptions)
func (*WrappedTx) UnwrapVirtualTx ¶
func (vid *WrappedTx) UnwrapVirtualTx(unwrapFun func(v *VirtualTransaction))
UnwrapVirtualTx calls callback only if it is virtualTx
func (*WrappedTx) WrappedInputs ¶
func (vid *WrappedTx) WrappedInputs() (ret []WrappedOutput)