Documentation ¶
Index ¶
- Constants
- Variables
- func OutputIDForMigratedFunds(milestoneHash iotago.MilestoneID, outputIndex uint16) iotago.OutputID
- func ParseBlockID(ms *marshalutil.MarshalUtil) (iotago.BlockID, error)
- func ParseOutputID(ms *marshalutil.MarshalUtil) (iotago.OutputID, error)
- type IterateOption
- type IterateOptions
- type LexicalOrderedOutputs
- type LexicalOrderedSpents
- type LookupKey
- type Manager
- func (u *Manager) AddUnspentOutput(unspentOutput *Output) error
- func (u *Manager) ApplyConfirmation(msIndex iotago.MilestoneIndex, newOutputs Outputs, newSpents Spents, ...) error
- func (u *Manager) ApplyConfirmationWithoutLocking(msIndex iotago.MilestoneIndex, newOutputs Outputs, newSpents Spents, ...) error
- func (u *Manager) CheckLedgerState(tokenSupply uint64) error
- func (u *Manager) ClearLedger(pruneReceipts bool) (err error)
- func (u *Manager) ComputeLedgerBalance(options ...IterateOption) (balance uint64, count int, err error)
- func (u *Manager) ForEachOutput(consumer OutputConsumer, options ...IterateOption) error
- func (u *Manager) ForEachReceiptTuple(consumer ReceiptTupleConsumer, options ...IterateOption) error
- func (u *Manager) ForEachReceiptTupleMigratedAt(migratedAtIndex iotago.MilestoneIndex, consumer ReceiptTupleConsumer, ...) error
- func (u *Manager) ForEachSpentOutput(consumer SpentConsumer, options ...IterateOption) error
- func (u *Manager) ForEachSpentTreasuryOutput(consumer TreasuryOutputConsumer, options ...IterateOption) error
- func (u *Manager) ForEachTreasuryOutput(consumer TreasuryOutputConsumer, options ...IterateOption) error
- func (u *Manager) ForEachUnspentOutput(consumer OutputConsumer, options ...IterateOption) error
- func (u *Manager) ForEachUnspentOutputID(consumer OutputIDConsumer, options ...IterateOption) error
- func (u *Manager) IsOutputIDUnspentWithoutLocking(outputID iotago.OutputID) (bool, error)
- func (u *Manager) IsOutputUnspentWithoutLocking(output *Output) (bool, error)
- func (u *Manager) KVStore() kvstore.KVStore
- func (u *Manager) LedgerStateSHA256Sum() ([]byte, error)
- func (u *Manager) MilestoneDiff(msIndex iotago.MilestoneIndex) (*MilestoneDiff, error)
- func (u *Manager) MilestoneDiffWithoutLocking(msIndex iotago.MilestoneIndex) (*MilestoneDiff, error)
- func (u *Manager) PruneMilestoneIndexWithoutLocking(msIndex iotago.MilestoneIndex, pruneReceipts bool, ...) error
- func (u *Manager) ReadLedgerIndex() (iotago.MilestoneIndex, error)
- func (u *Manager) ReadLedgerIndexWithoutLocking() (iotago.MilestoneIndex, error)
- func (u *Manager) ReadLockLedger()
- func (u *Manager) ReadOutputByOutputID(outputID iotago.OutputID) (*Output, error)
- func (u *Manager) ReadOutputByOutputIDWithoutLocking(outputID iotago.OutputID) (*Output, error)
- func (u *Manager) ReadRawOutputBytesByOutputIDWithoutLocking(outputID iotago.OutputID) ([]byte, error)
- func (u *Manager) ReadSpentForOutputIDWithoutLocking(outputID iotago.OutputID) (*Spent, error)
- func (u *Manager) ReadUnlockLedger()
- func (u *Manager) RollbackConfirmation(msIndex iotago.MilestoneIndex, newOutputs Outputs, newSpents Spents, ...) error
- func (u *Manager) RollbackConfirmationWithoutLocking(msIndex iotago.MilestoneIndex, newOutputs Outputs, newSpents Spents, ...) error
- func (u *Manager) SearchHighestReceiptMigratedAtIndex(options ...IterateOption) (iotago.MilestoneIndex, error)
- func (u *Manager) SpentOutputs(options ...IterateOption) (Spents, error)
- func (u *Manager) StoreLedgerIndex(msIndex iotago.MilestoneIndex) error
- func (u *Manager) StoreUnspentTreasuryOutput(to *TreasuryOutput) error
- func (u *Manager) UnspentOutputs(options ...IterateOption) (Outputs, error)
- func (u *Manager) UnspentOutputsIDs(options ...IterateOption) (iotago.OutputIDs, error)
- func (u *Manager) UnspentTreasuryOutputWithoutLocking() (*TreasuryOutput, error)
- func (u *Manager) WriteLockLedger()
- func (u *Manager) WriteUnlockLedger()
- type MilestoneDiff
- type Output
- func CreateOutput(outputID iotago.OutputID, blockID iotago.BlockID, ...) *Output
- func NewOutput(blockID iotago.BlockID, msIndexBooked iotago.MilestoneIndex, ...) (*Output, error)
- func OutputFromSnapshotReader(reader io.ReadSeeker, protoParams *iotago.ProtocolParameters) (*Output, error)
- func ReceiptToOutputs(r *iotago.ReceiptMilestoneOpt, milestoneID iotago.MilestoneID, ...) ([]*Output, error)
- func (o *Output) BlockID() iotago.BlockID
- func (o *Output) Bytes() []byte
- func (o *Output) Deposit() uint64
- func (o *Output) KVStorableKey() (key []byte)
- func (o *Output) KVStorableValue() (value []byte)
- func (o *Output) MapKey() string
- func (o *Output) MilestoneIndexBooked() iotago.MilestoneIndex
- func (o *Output) MilestoneTimestampBooked() uint32
- func (o *Output) Output() iotago.Output
- func (o *Output) OutputID() iotago.OutputID
- func (o *Output) OutputType() iotago.OutputType
- func (o *Output) SnapshotBytes() []byte
- func (o *Output) UnspentLookupKey() LookupKey
- type OutputConsumer
- type OutputIDConsumer
- type Outputs
- type ReceiptTuple
- type ReceiptTupleConsumer
- type Spent
- func (s *Spent) BlockID() iotago.BlockID
- func (s *Spent) Deposit() uint64
- func (s *Spent) KVStorableKey() (key []byte)
- func (s *Spent) KVStorableValue() (value []byte)
- func (s *Spent) MapKey() string
- func (s *Spent) MilestoneIndexSpent() iotago.MilestoneIndex
- func (s *Spent) MilestoneTimestampSpent() uint32
- func (s *Spent) Output() *Output
- func (s *Spent) OutputID() iotago.OutputID
- func (s *Spent) OutputType() iotago.OutputType
- func (s *Spent) SnapshotBytes() []byte
- func (s *Spent) TransactionIDSpent() iotago.TransactionID
- type SpentConsumer
- type Spents
- type TreasuryMutationTuple
- type TreasuryOutput
- type TreasuryOutputConsumer
Constants ¶
const ( UTXOStoreKeyPrefixLedgerMilestoneIndex byte = 0 // UTXOStoreKeyPrefixOutput defines the prefix for Output and Spent storage. UTXOStoreKeyPrefixOutput byte = 1 // UTXOStoreKeyPrefixOutputSpent defines the prefix for Track spent/unspent Outputs. UTXOStoreKeyPrefixOutputSpent byte = 2 UTXOStoreKeyPrefixOutputUnspent byte = 3 // UTXOStoreKeyPrefixMilestoneDiffs defines the prefix for Milestone diffs. UTXOStoreKeyPrefixMilestoneDiffs byte = 4 // UTXOStoreKeyPrefixTreasuryOutput defines the prefix for the Treasury Output. UTXOStoreKeyPrefixTreasuryOutput byte = 5 UTXOStoreKeyPrefixReceipts byte = 6 )
const ( // A prefix which denotes a spent treasury output. // Do not modify the value since we're writing this as a bool. TreasuryOutputSpentPrefix = 1 // A prefix which denotes an unspent treasury output. // Do not modify the value since we're writing this as a bool. TreasuryOutputUnspentPrefix = 0 )
Variables ¶
var ( // ErrInvalidTreasuryState is returned when the state of the treasury is invalid. ErrInvalidTreasuryState = errors.New("invalid treasury state") )
var ( // ErrOutputsSumNotEqualTotalSupply is returned if the sum of the output deposits is not equal the total supply of tokens. ErrOutputsSumNotEqualTotalSupply = errors.New("accumulated output balance is not equal to total supply") )
Functions ¶
func OutputIDForMigratedFunds ¶
func OutputIDForMigratedFunds(milestoneHash iotago.MilestoneID, outputIndex uint16) iotago.OutputID
OutputIDForMigratedFunds returns the UTXO ID for a migrated funds entry given the milestone containing the receipt and the index of the entry.
func ParseBlockID ¶
func ParseBlockID(ms *marshalutil.MarshalUtil) (iotago.BlockID, error)
func ParseOutputID ¶
func ParseOutputID(ms *marshalutil.MarshalUtil) (iotago.OutputID, error)
Types ¶
type IterateOption ¶
type IterateOption func(*IterateOptions)
func ReadLockLedger ¶
func ReadLockLedger(lockLedger bool) IterateOption
type IterateOptions ¶
type IterateOptions struct {
// contains filtered or unexported fields
}
type LexicalOrderedOutputs ¶
type LexicalOrderedOutputs []*Output
LexicalOrderedOutputs are outputs ordered in lexical order by their outputID.
func (LexicalOrderedOutputs) Len ¶
func (l LexicalOrderedOutputs) Len() int
func (LexicalOrderedOutputs) Less ¶
func (l LexicalOrderedOutputs) Less(i, j int) bool
func (LexicalOrderedOutputs) Swap ¶
func (l LexicalOrderedOutputs) Swap(i, j int)
type LexicalOrderedSpents ¶
type LexicalOrderedSpents []*Spent
LexicalOrderedSpents are spents ordered in lexical order by their outputID.
func (LexicalOrderedSpents) Len ¶
func (l LexicalOrderedSpents) Len() int
func (LexicalOrderedSpents) Less ¶
func (l LexicalOrderedSpents) Less(i, j int) bool
func (LexicalOrderedSpents) Swap ¶
func (l LexicalOrderedSpents) Swap(i, j int)
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func (*Manager) AddUnspentOutput ¶
func (*Manager) ApplyConfirmation ¶
func (u *Manager) ApplyConfirmation(msIndex iotago.MilestoneIndex, newOutputs Outputs, newSpents Spents, tm *TreasuryMutationTuple, rt *ReceiptTuple) error
func (*Manager) ApplyConfirmationWithoutLocking ¶
func (u *Manager) ApplyConfirmationWithoutLocking(msIndex iotago.MilestoneIndex, newOutputs Outputs, newSpents Spents, tm *TreasuryMutationTuple, rt *ReceiptTuple) error
func (*Manager) CheckLedgerState ¶
func (*Manager) ClearLedger ¶
ClearLedger removes all entries from the UTXO ledger (spent, unspent, diff, receipts, treasury).
func (*Manager) ComputeLedgerBalance ¶
func (u *Manager) ComputeLedgerBalance(options ...IterateOption) (balance uint64, count int, err error)
func (*Manager) ForEachOutput ¶
func (u *Manager) ForEachOutput(consumer OutputConsumer, options ...IterateOption) error
func (*Manager) ForEachReceiptTuple ¶
func (u *Manager) ForEachReceiptTuple(consumer ReceiptTupleConsumer, options ...IterateOption) error
ForEachReceiptTuple iterates over all stored receipt tuples.
func (*Manager) ForEachReceiptTupleMigratedAt ¶
func (u *Manager) ForEachReceiptTupleMigratedAt(migratedAtIndex iotago.MilestoneIndex, consumer ReceiptTupleConsumer, options ...IterateOption) error
ForEachReceiptTupleMigratedAt iterates over all stored receipt tuples for a given migrated at index.
func (*Manager) ForEachSpentOutput ¶
func (u *Manager) ForEachSpentOutput(consumer SpentConsumer, options ...IterateOption) error
func (*Manager) ForEachSpentTreasuryOutput ¶
func (u *Manager) ForEachSpentTreasuryOutput(consumer TreasuryOutputConsumer, options ...IterateOption) error
func (*Manager) ForEachTreasuryOutput ¶
func (u *Manager) ForEachTreasuryOutput(consumer TreasuryOutputConsumer, options ...IterateOption) error
ForEachTreasuryOutput iterates over all stored treasury outputs.
func (*Manager) ForEachUnspentOutput ¶
func (u *Manager) ForEachUnspentOutput(consumer OutputConsumer, options ...IterateOption) error
func (*Manager) ForEachUnspentOutputID ¶
func (u *Manager) ForEachUnspentOutputID(consumer OutputIDConsumer, options ...IterateOption) error
func (*Manager) IsOutputIDUnspentWithoutLocking ¶
func (*Manager) IsOutputUnspentWithoutLocking ¶
func (*Manager) LedgerStateSHA256Sum ¶
func (*Manager) MilestoneDiff ¶
func (u *Manager) MilestoneDiff(msIndex iotago.MilestoneIndex) (*MilestoneDiff, error)
func (*Manager) MilestoneDiffWithoutLocking ¶
func (u *Manager) MilestoneDiffWithoutLocking(msIndex iotago.MilestoneIndex) (*MilestoneDiff, error)
func (*Manager) PruneMilestoneIndexWithoutLocking ¶
func (u *Manager) PruneMilestoneIndexWithoutLocking(msIndex iotago.MilestoneIndex, pruneReceipts bool, receiptMigratedAtIndex ...iotago.MilestoneIndex) error
func (*Manager) ReadLedgerIndex ¶
func (u *Manager) ReadLedgerIndex() (iotago.MilestoneIndex, error)
func (*Manager) ReadLedgerIndexWithoutLocking ¶
func (u *Manager) ReadLedgerIndexWithoutLocking() (iotago.MilestoneIndex, error)
func (*Manager) ReadLockLedger ¶
func (u *Manager) ReadLockLedger()
func (*Manager) ReadOutputByOutputID ¶
func (*Manager) ReadOutputByOutputIDWithoutLocking ¶
func (*Manager) ReadRawOutputBytesByOutputIDWithoutLocking ¶
func (*Manager) ReadSpentForOutputIDWithoutLocking ¶
func (*Manager) ReadUnlockLedger ¶
func (u *Manager) ReadUnlockLedger()
func (*Manager) RollbackConfirmation ¶
func (u *Manager) RollbackConfirmation(msIndex iotago.MilestoneIndex, newOutputs Outputs, newSpents Spents, tm *TreasuryMutationTuple, rt *ReceiptTuple) error
func (*Manager) RollbackConfirmationWithoutLocking ¶
func (u *Manager) RollbackConfirmationWithoutLocking(msIndex iotago.MilestoneIndex, newOutputs Outputs, newSpents Spents, tm *TreasuryMutationTuple, rt *ReceiptTuple) error
func (*Manager) SearchHighestReceiptMigratedAtIndex ¶
func (u *Manager) SearchHighestReceiptMigratedAtIndex(options ...IterateOption) (iotago.MilestoneIndex, error)
SearchHighestReceiptMigratedAtIndex searches the highest migratedAt of all stored receipts.
func (*Manager) SpentOutputs ¶
func (u *Manager) SpentOutputs(options ...IterateOption) (Spents, error)
func (*Manager) StoreLedgerIndex ¶
func (u *Manager) StoreLedgerIndex(msIndex iotago.MilestoneIndex) error
func (*Manager) StoreUnspentTreasuryOutput ¶
func (u *Manager) StoreUnspentTreasuryOutput(to *TreasuryOutput) error
StoreUnspentTreasuryOutput stores the given unspent treasury output and also deletes any existing unspent one in the same procedure.
func (*Manager) UnspentOutputs ¶
func (u *Manager) UnspentOutputs(options ...IterateOption) (Outputs, error)
func (*Manager) UnspentOutputsIDs ¶
func (u *Manager) UnspentOutputsIDs(options ...IterateOption) (iotago.OutputIDs, error)
func (*Manager) UnspentTreasuryOutputWithoutLocking ¶
func (u *Manager) UnspentTreasuryOutputWithoutLocking() (*TreasuryOutput, error)
UnspentTreasuryOutputWithoutLocking returns the unspent treasury output.
func (*Manager) WriteLockLedger ¶
func (u *Manager) WriteLockLedger()
func (*Manager) WriteUnlockLedger ¶
func (u *Manager) WriteUnlockLedger()
type MilestoneDiff ¶
type MilestoneDiff struct { // The index of the milestone. Index iotago.MilestoneIndex // The outputs newly generated with this diff. Outputs Outputs // The outputs spent with this diff. Spents Spents // The treasury output this diff generated. TreasuryOutput *TreasuryOutput // The treasury output this diff consumed. SpentTreasuryOutput *TreasuryOutput }
MilestoneDiff represents the generated and spent outputs by a milestone's confirmation.
func (*MilestoneDiff) KVStorableKey ¶
func (ms *MilestoneDiff) KVStorableKey() []byte
func (*MilestoneDiff) KVStorableValue ¶
func (ms *MilestoneDiff) KVStorableValue() []byte
func (*MilestoneDiff) SHA256Sum ¶
func (ms *MilestoneDiff) SHA256Sum() ([]byte, error)
SHA256Sum computes the sha256 of the milestone diff byte representation.
type Output ¶
type Output struct {
// contains filtered or unexported fields
}
func CreateOutput ¶
func NewOutput ¶
func NewOutput(blockID iotago.BlockID, msIndexBooked iotago.MilestoneIndex, msTimestampBooked uint32, transaction *iotago.Transaction, index uint16) (*Output, error)
func OutputFromSnapshotReader ¶
func OutputFromSnapshotReader(reader io.ReadSeeker, protoParams *iotago.ProtocolParameters) (*Output, error)
func ReceiptToOutputs ¶
func ReceiptToOutputs(r *iotago.ReceiptMilestoneOpt, milestoneID iotago.MilestoneID, msIndex iotago.MilestoneIndex, msTimestamp uint32) ([]*Output, error)
ReceiptToOutputs extracts the migrated funds to outputs.
func (*Output) KVStorableKey ¶
func (*Output) KVStorableValue ¶
func (*Output) MilestoneIndexBooked ¶
func (o *Output) MilestoneIndexBooked() iotago.MilestoneIndex
func (*Output) MilestoneTimestampBooked ¶
func (*Output) OutputType ¶
func (o *Output) OutputType() iotago.OutputType
func (*Output) SnapshotBytes ¶
func (*Output) UnspentLookupKey ¶
type OutputConsumer ¶
OutputConsumer is a function that consumes an output. Returning false from this function indicates to abort the iteration.
type OutputIDConsumer ¶
OutputIDConsumer is a function that consumes an output ID. Returning false from this function indicates to abort the iteration.
type ReceiptTuple ¶
type ReceiptTuple struct { // The actual receipt. Receipt *iotago.ReceiptMilestoneOpt `json:"receipt"` // The index of the milestone which included the receipt. MilestoneIndex iotago.MilestoneIndex `json:"milestoneIndex"` }
ReceiptTuple contains a receipt and the index of the milestone which contained the receipt.
func (*ReceiptTuple) KVStorableKey ¶
func (rt *ReceiptTuple) KVStorableKey() (key []byte)
func (*ReceiptTuple) KVStorableValue ¶
func (rt *ReceiptTuple) KVStorableValue() (value []byte)
type ReceiptTupleConsumer ¶
type ReceiptTupleConsumer func(rt *ReceiptTuple) bool
ReceiptTupleConsumer is a function that consumes a receipt tuple. Returning false from this function indicates to abort the iteration.
type Spent ¶
type Spent struct {
// contains filtered or unexported fields
}
Spent are already spent TXOs (transaction outputs).
func NewSpent ¶
func NewSpent(output *Output, transactionIDSpent iotago.TransactionID, msIndexSpent iotago.MilestoneIndex, msTimestampSpent uint32) *Spent
func SpentFromSnapshotReader ¶
func SpentFromSnapshotReader(reader io.ReadSeeker, protoParams *iotago.ProtocolParameters, msIndexSpent iotago.MilestoneIndex, msTimestampSpent uint32) (*Spent, error)
func (*Spent) KVStorableKey ¶
func (*Spent) KVStorableValue ¶
func (*Spent) MilestoneIndexSpent ¶
func (s *Spent) MilestoneIndexSpent() iotago.MilestoneIndex
MilestoneIndexSpent returns the index of the milestone that spent the output.
func (*Spent) MilestoneTimestampSpent ¶
MilestoneTimestampSpent returns the timestamp of the milestone that spent the output.
func (*Spent) OutputType ¶
func (s *Spent) OutputType() iotago.OutputType
func (*Spent) SnapshotBytes ¶
func (*Spent) TransactionIDSpent ¶
func (s *Spent) TransactionIDSpent() iotago.TransactionID
TransactionIDSpent returns the ID of the transaction that spent the output.
type SpentConsumer ¶
SpentConsumer is a function that consumes a spent output. Returning false from this function indicates to abort the iteration.
type TreasuryMutationTuple ¶
type TreasuryMutationTuple struct { // The treasury transaction causes this mutation. NewOutput *TreasuryOutput // The previous treasury output which funded the new transaction. SpentOutput *TreasuryOutput }
TreasuryMutationTuple holds data about a mutation happening to the treasury.
func ReceiptToTreasuryMutation ¶
func ReceiptToTreasuryMutation(r *iotago.ReceiptMilestoneOpt, unspentTreasuryOutput *TreasuryOutput, newMilestoneID iotago.MilestoneID) (*TreasuryMutationTuple, error)
ReceiptToTreasuryMutation converts a receipt to a treasury mutation tuple.
type TreasuryOutput ¶
type TreasuryOutput struct { // The ID of the milestone which generated this output. MilestoneID iotago.MilestoneID // The amount residing on this output. Amount uint64 // Whether this output was already spent Spent bool }
TreasuryOutput represents the output of a treasury transaction.
func (*TreasuryOutput) KVStorableKey ¶
func (t *TreasuryOutput) KVStorableKey() (key []byte)
func (*TreasuryOutput) KVStorableValue ¶
func (t *TreasuryOutput) KVStorableValue() (value []byte)
func (*TreasuryOutput) MarshalJSON ¶
func (t *TreasuryOutput) MarshalJSON() ([]byte, error)
func (*TreasuryOutput) UnmarshalJSON ¶
func (t *TreasuryOutput) UnmarshalJSON(bytes []byte) error
type TreasuryOutputConsumer ¶
type TreasuryOutputConsumer func(output *TreasuryOutput) bool
TreasuryOutputConsumer is a function that consumes an output. Returning false from this function indicates to abort the iteration.