Documentation ¶
Index ¶
- Constants
- Variables
- func OutputIDForMigratedFunds(milestoneHash iotago.MilestoneID, outputIndex uint16) iotago.UTXOInputID
- func ParseMessageID(ms *marshalutil.MarshalUtil) (hornet.MessageID, error)
- func ParseOutputID(ms *marshalutil.MarshalUtil) (*iotago.UTXOInputID, error)
- type BalanceDiff
- type LexicalOrderedOutputs
- type LexicalOrderedSpents
- type Manager
- func (u *Manager) AddUnspentOutput(unspentOutput *Output) error
- func (u *Manager) AddressBalance(address iotago.Address) (balance uint64, dustAllowed bool, ledgerIndex milestone.Index, err error)
- func (u *Manager) AddressBalanceWithoutLocking(address iotago.Address) (balance uint64, dustAllowed bool, err error)
- func (u *Manager) ApplyConfirmation(msIndex milestone.Index, newOutputs Outputs, newSpents Spents, ...) error
- func (u *Manager) ApplyConfirmationWithoutLocking(msIndex milestone.Index, newOutputs Outputs, newSpents Spents, ...) error
- func (u *Manager) CheckLedgerState() error
- func (u *Manager) ClearLedger(pruneReceipts bool) (err error)
- func (u *Manager) ComputeBalance(options ...UTXOIterateOption) (balance uint64, count int, err error)
- func (u *Manager) ForEachOutput(consumer OutputConsumer, options ...UTXOIterateOption) error
- func (u *Manager) ForEachReceiptTuple(consumer ReceiptTupleConsumer, options ...UTXOIterateOption) error
- func (u *Manager) ForEachReceiptTupleMigratedAt(migratedAtIndex milestone.Index, consumer ReceiptTupleConsumer, ...) error
- func (u *Manager) ForEachSpentOutput(consumer SpentConsumer, options ...UTXOIterateOption) error
- func (u *Manager) ForEachSpentTreasuryOutput(consumer TreasuryOutputConsumer, options ...UTXOIterateOption) error
- func (u *Manager) ForEachTreasuryOutput(consumer TreasuryOutputConsumer, options ...UTXOIterateOption) error
- func (u *Manager) ForEachUnspentOutput(consumer OutputConsumer, options ...UTXOIterateOption) error
- func (u *Manager) IsOutputIDUnspentWithoutLocking(outputID *iotago.UTXOInputID) (bool, error)
- func (u *Manager) IsOutputUnspentWithoutLocking(output *Output) (bool, error)
- func (u *Manager) LedgerStateSHA256Sum() ([]byte, error)
- func (u *Manager) MilestoneDiff(msIndex milestone.Index) (*MilestoneDiff, error)
- func (u *Manager) MilestoneDiffWithoutLocking(msIndex milestone.Index) (*MilestoneDiff, error)
- func (u *Manager) PruneMilestoneIndexWithoutLocking(msIndex milestone.Index, pruneReceipts bool, receiptMigratedAtIndex ...uint32) error
- func (u *Manager) ReadDustForAddress(address iotago.Address, applyDiff *BalanceDiff) (dustAllowanceBalance uint64, dustOutputCount int64, err error)
- func (u *Manager) ReadLedgerIndex() (milestone.Index, error)
- func (u *Manager) ReadLedgerIndexWithoutLocking() (milestone.Index, error)
- func (u *Manager) ReadLockLedger()
- func (u *Manager) ReadOutputByOutputID(outputID *iotago.UTXOInputID) (*Output, error)
- func (u *Manager) ReadOutputByOutputIDWithoutLocking(outputID *iotago.UTXOInputID) (*Output, error)
- func (u *Manager) ReadSpentForOutputIDWithoutLocking(outputID *iotago.UTXOInputID) (*Spent, error)
- func (u *Manager) ReadSpentForOutputWithoutLocking(output *Output) (*Spent, error)
- func (u *Manager) ReadUnlockLedger()
- func (u *Manager) RollbackConfirmation(msIndex milestone.Index, newOutputs Outputs, newSpents Spents, ...) error
- func (u *Manager) RollbackConfirmationWithoutLocking(msIndex milestone.Index, newOutputs Outputs, newSpents Spents, ...) error
- func (u *Manager) SearchHighestReceiptMigratedAtIndex(options ...UTXOIterateOption) (uint32, error)
- func (u *Manager) SpentOutputs(options ...UTXOIterateOption) (Spents, error)
- func (u *Manager) StoreLedgerIndex(msIndex milestone.Index) error
- func (u *Manager) StoreUnspentTreasuryOutput(to *TreasuryOutput) error
- func (u *Manager) UnspentOutputs(options ...UTXOIterateOption) ([]*Output, error)
- func (u *Manager) UnspentTreasuryOutputWithoutLocking() (*TreasuryOutput, error)
- func (u *Manager) WriteLockLedger()
- func (u *Manager) WriteUnlockLedger()
- type MilestoneDiff
- type Output
- func CreateOutput(outputID *iotago.UTXOInputID, messageID hornet.MessageID, ...) *Output
- func NewOutput(messageID hornet.MessageID, transaction *iotago.Transaction, index uint16) (*Output, error)
- func ReceiptToOutputs(r *iotago.Receipt, msgID hornet.MessageID, msID *iotago.MilestoneID) ([]*Output, error)
- func (o *Output) Address() iotago.Address
- func (o *Output) AddressBytes() []byte
- func (o *Output) Amount() uint64
- func (o *Output) MessageID() hornet.MessageID
- func (o *Output) OutputID() *iotago.UTXOInputID
- func (o *Output) OutputType() iotago.OutputType
- func (o *Output) UTXOInput() *iotago.UTXOInput
- type OutputConsumer
- type Outputs
- type ReceiptTuple
- type ReceiptTupleConsumer
- type Spent
- func (s *Spent) Address() iotago.Address
- func (s *Spent) Amount() uint64
- func (s *Spent) ConfirmationIndex() milestone.Index
- func (s *Spent) MessageID() hornet.MessageID
- func (s *Spent) Output() *Output
- func (s *Spent) OutputID() *iotago.UTXOInputID
- func (s *Spent) OutputType() iotago.OutputType
- func (s *Spent) TargetTransactionID() *iotago.TransactionID
- type SpentConsumer
- type Spents
- type TreasuryMutationTuple
- type TreasuryOutput
- type TreasuryOutputConsumer
- type UTXOIterateOption
- type UTXOIterateOptions
Constants ¶
const ( UTXOStoreKeyPrefixLedgerMilestoneIndex byte = 0 UTXOStoreKeyPrefixOutput byte = 1 UTXOStoreKeyPrefixUnspent byte = 2 UTXOStoreKeyPrefixSpent byte = 3 UTXOStoreKeyPrefixMilestoneDiffs byte = 4 UTXOStoreKeyPrefixBalances byte = 5 UTXOStoreKeyPrefixTreasuryOutput byte = 6 UTXOStoreKeyPrefixReceipts byte = 7 )
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 )
const (
OutputIDLength = iotago.TransactionIDLength + serializer.UInt16ByteSize
)
Variables ¶
var ( // ErrInvalidBalancesTotalSupply is returned when the sum of all balances does not match total supply. ErrInvalidBalancesTotalSupply = errors.New("invalid balances total supply") // ErrInvalidBalanceOnAddress is returned when the balance on an address is invalid. ErrInvalidBalanceOnAddress = errors.New("invalid balance on address") // ErrInvalidDustForAddress is returned when the dust for an address is invalid. ErrInvalidDustForAddress = errors.New("invalid dust for address") )
var ( // Returned if the size of the given address is incorrect. ErrInvalidAddressSize = errors.New("invalid address size") // 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") )
var ( // Returned when the state of the treasury is invalid. ErrInvalidTreasuryState = errors.New("invalid treasury state") )
Functions ¶
func OutputIDForMigratedFunds ¶
func OutputIDForMigratedFunds(milestoneHash iotago.MilestoneID, outputIndex uint16) iotago.UTXOInputID
OutputIDForMigratedFunds returns the UTXO ID for a migrated funds entry given the milestone containing the receipt and the index of the entry.
func ParseMessageID ¶ added in v1.1.0
func ParseMessageID(ms *marshalutil.MarshalUtil) (hornet.MessageID, error)
func ParseOutputID ¶ added in v1.1.0
func ParseOutputID(ms *marshalutil.MarshalUtil) (*iotago.UTXOInputID, error)
Types ¶
type BalanceDiff ¶
type BalanceDiff struct {
// contains filtered or unexported fields
}
func NewBalanceDiff ¶
func NewBalanceDiff() *BalanceDiff
func (*BalanceDiff) DiffForAddress ¶
type LexicalOrderedOutputs ¶ added in v1.2.0
type LexicalOrderedOutputs []*Output
LexicalOrderedOutputs are outputs ordered in lexical order by their outputID.
func (LexicalOrderedOutputs) Len ¶ added in v1.2.0
func (l LexicalOrderedOutputs) Len() int
func (LexicalOrderedOutputs) Less ¶ added in v1.2.0
func (l LexicalOrderedOutputs) Less(i, j int) bool
func (LexicalOrderedOutputs) Swap ¶ added in v1.2.0
func (l LexicalOrderedOutputs) Swap(i, j int)
type LexicalOrderedSpents ¶ added in v1.2.0
type LexicalOrderedSpents []*Spent
LexicalOrderedOutputs are spents ordered in lexical order by their outputID.
func (LexicalOrderedSpents) Len ¶ added in v1.2.0
func (l LexicalOrderedSpents) Len() int
func (LexicalOrderedSpents) Less ¶ added in v1.2.0
func (l LexicalOrderedSpents) Less(i, j int) bool
func (LexicalOrderedSpents) Swap ¶ added in v1.2.0
func (l LexicalOrderedSpents) Swap(i, j int)
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func (*Manager) AddUnspentOutput ¶
func (*Manager) AddressBalance ¶
func (*Manager) AddressBalanceWithoutLocking ¶
func (*Manager) ApplyConfirmation ¶
func (u *Manager) ApplyConfirmation(msIndex milestone.Index, newOutputs Outputs, newSpents Spents, tm *TreasuryMutationTuple, rt *ReceiptTuple) error
func (*Manager) ApplyConfirmationWithoutLocking ¶
func (u *Manager) ApplyConfirmationWithoutLocking(msIndex milestone.Index, 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, balances, receipts, treasury).
func (*Manager) ComputeBalance ¶
func (u *Manager) ComputeBalance(options ...UTXOIterateOption) (balance uint64, count int, err error)
func (*Manager) ForEachOutput ¶
func (u *Manager) ForEachOutput(consumer OutputConsumer, options ...UTXOIterateOption) error
func (*Manager) ForEachReceiptTuple ¶
func (u *Manager) ForEachReceiptTuple(consumer ReceiptTupleConsumer, options ...UTXOIterateOption) error
ForEachReceiptTuple iterates over all stored receipt tuples.
func (*Manager) ForEachReceiptTupleMigratedAt ¶
func (u *Manager) ForEachReceiptTupleMigratedAt(migratedAtIndex milestone.Index, consumer ReceiptTupleConsumer, options ...UTXOIterateOption) error
ForEachReceiptTupleMigratedAt iterates over all stored receipt tuples for a given migrated at index.
func (*Manager) ForEachSpentOutput ¶
func (u *Manager) ForEachSpentOutput(consumer SpentConsumer, options ...UTXOIterateOption) error
func (*Manager) ForEachSpentTreasuryOutput ¶
func (u *Manager) ForEachSpentTreasuryOutput(consumer TreasuryOutputConsumer, options ...UTXOIterateOption) error
func (*Manager) ForEachTreasuryOutput ¶
func (u *Manager) ForEachTreasuryOutput(consumer TreasuryOutputConsumer, options ...UTXOIterateOption) error
ForEachTreasuryOutput iterates over all stored treasury outputs.
func (*Manager) ForEachUnspentOutput ¶
func (u *Manager) ForEachUnspentOutput(consumer OutputConsumer, options ...UTXOIterateOption) error
func (*Manager) IsOutputIDUnspentWithoutLocking ¶ added in v1.2.0
func (u *Manager) IsOutputIDUnspentWithoutLocking(outputID *iotago.UTXOInputID) (bool, error)
func (*Manager) IsOutputUnspentWithoutLocking ¶
func (*Manager) LedgerStateSHA256Sum ¶ added in v1.2.0
func (*Manager) MilestoneDiff ¶ added in v1.0.5
func (u *Manager) MilestoneDiff(msIndex milestone.Index) (*MilestoneDiff, error)
func (*Manager) MilestoneDiffWithoutLocking ¶ added in v1.0.5
func (u *Manager) MilestoneDiffWithoutLocking(msIndex milestone.Index) (*MilestoneDiff, error)
func (*Manager) PruneMilestoneIndexWithoutLocking ¶
func (*Manager) ReadDustForAddress ¶
func (*Manager) ReadLedgerIndexWithoutLocking ¶
func (*Manager) ReadLockLedger ¶
func (u *Manager) ReadLockLedger()
func (*Manager) ReadOutputByOutputID ¶
func (u *Manager) ReadOutputByOutputID(outputID *iotago.UTXOInputID) (*Output, error)
func (*Manager) ReadOutputByOutputIDWithoutLocking ¶
func (u *Manager) ReadOutputByOutputIDWithoutLocking(outputID *iotago.UTXOInputID) (*Output, error)
func (*Manager) ReadSpentForOutputIDWithoutLocking ¶ added in v1.2.0
func (u *Manager) ReadSpentForOutputIDWithoutLocking(outputID *iotago.UTXOInputID) (*Spent, error)
func (*Manager) ReadSpentForOutputWithoutLocking ¶ added in v1.2.0
func (*Manager) ReadUnlockLedger ¶
func (u *Manager) ReadUnlockLedger()
func (*Manager) RollbackConfirmation ¶
func (u *Manager) RollbackConfirmation(msIndex milestone.Index, newOutputs Outputs, newSpents Spents, tm *TreasuryMutationTuple, rt *ReceiptTuple) error
func (*Manager) RollbackConfirmationWithoutLocking ¶
func (u *Manager) RollbackConfirmationWithoutLocking(msIndex milestone.Index, newOutputs Outputs, newSpents Spents, tm *TreasuryMutationTuple, rt *ReceiptTuple) error
func (*Manager) SearchHighestReceiptMigratedAtIndex ¶
func (u *Manager) SearchHighestReceiptMigratedAtIndex(options ...UTXOIterateOption) (uint32, error)
SearchHighestReceiptMigratedAtIndex searches the highest migratedAt of all stored receipts.
func (*Manager) SpentOutputs ¶
func (u *Manager) SpentOutputs(options ...UTXOIterateOption) (Spents, error)
func (*Manager) StoreLedgerIndex ¶
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 ...UTXOIterateOption) ([]*Output, 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 milestone.Index // 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 // contains filtered or unexported fields }
MilestoneDiff represents the generated and spent outputs by a milestone's confirmation.
func (*MilestoneDiff) SHA256Sum ¶ added in v1.2.0
func (ms *MilestoneDiff) SHA256Sum() ([]byte, error)
compute the sha256 of the milestone diff byte representation
type Output ¶
type Output struct {
// contains filtered or unexported fields
}
func CreateOutput ¶
func CreateOutput(outputID *iotago.UTXOInputID, messageID hornet.MessageID, outputType iotago.OutputType, address iotago.Address, amount uint64) *Output
func ReceiptToOutputs ¶
func ReceiptToOutputs(r *iotago.Receipt, msgID hornet.MessageID, msID *iotago.MilestoneID) ([]*Output, error)
ReceiptToOutputs extracts the migrated funds to outputs.
func (*Output) AddressBytes ¶ added in v1.1.0
func (*Output) OutputID ¶
func (o *Output) OutputID() *iotago.UTXOInputID
func (*Output) OutputType ¶
func (o *Output) OutputType() iotago.OutputType
type OutputConsumer ¶
type Outputs ¶
type Outputs []*Output
func (Outputs) InputToOutputMapping ¶
func (o Outputs) InputToOutputMapping() (iotago.InputToOutputMapping, error)
type ReceiptTuple ¶
type ReceiptTuple struct { // The actual receipt. Receipt *iotago.Receipt `json:"receipt"` // The index of the milestone which included the receipt. MilestoneIndex milestone.Index `json:"milestoneIndex"` }
ReceiptTuple contains a receipt and the index of the milestone which contained the receipt.
type ReceiptTupleConsumer ¶
type ReceiptTupleConsumer func(rt *ReceiptTuple) bool
ReceiptTupleConsumer is a function that consumes a receipt tuple.
type Spent ¶
type Spent struct {
// contains filtered or unexported fields
}
Spent are already spent TXOs (transaction outputs) per address
func (*Spent) ConfirmationIndex ¶
func (*Spent) OutputID ¶
func (s *Spent) OutputID() *iotago.UTXOInputID
func (*Spent) OutputType ¶
func (s *Spent) OutputType() iotago.OutputType
func (*Spent) TargetTransactionID ¶
func (s *Spent) TargetTransactionID() *iotago.TransactionID
type SpentConsumer ¶
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.Receipt, unspentTreasuryOutput *TreasuryOutput, newMsID *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.
type TreasuryOutputConsumer ¶
type TreasuryOutputConsumer func(output *TreasuryOutput) bool
TreasuryOutputConsumer is a function that consumes an output.
type UTXOIterateOption ¶
type UTXOIterateOption func(*UTXOIterateOptions)
func FilterAddress ¶
func FilterAddress(address iotago.Address) UTXOIterateOption
func FilterOutputType ¶
func FilterOutputType(outputType iotago.OutputType) UTXOIterateOption
func MaxResultCount ¶
func MaxResultCount(count int) UTXOIterateOption
func ReadLockLedger ¶
func ReadLockLedger(lockLedger bool) UTXOIterateOption
type UTXOIterateOptions ¶
type UTXOIterateOptions struct {
// contains filtered or unexported fields
}