utxo

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 11 Imported by: ? 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

View Source
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
)
View Source
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

View Source
var (
	// ErrInvalidTreasuryState is returned when the state of the treasury is invalid.
	ErrInvalidTreasuryState = errors.New("invalid treasury state")
)

Functions

func ParseMessageID

func ParseMessageID(ms *marshalutil.MarshalUtil) (hornet.MessageID, error)

func ParseOutputID

func ParseOutputID(ms *marshalutil.MarshalUtil) (*iotago.UTXOInputID, error)

Types

type IterateOption

type IterateOption func(*IterateOptions)

func FilterAddress

func FilterAddress(address iotago.Address) IterateOption

func FilterOutputType

func FilterOutputType(outputType iotago.OutputType) IterateOption

func MaxResultCount

func MaxResultCount(count int) IterateOption

type IterateOptions

type IterateOptions struct {
	// contains filtered or unexported fields
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func New

func New(store kvstore.KVStore) *Manager

func (*Manager) AddressBalance

func (u *Manager) AddressBalance(address iotago.Address) (balance uint64, dustAllowed bool, ledgerIndex milestone.Index, err error)

func (*Manager) AddressBalanceWithoutLocking

func (u *Manager) AddressBalanceWithoutLocking(address iotago.Address) (balance uint64, dustAllowed bool, err 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 milestone.Index, 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) ForEachUnspentOutput

func (u *Manager) ForEachUnspentOutput(consumer OutputConsumer, options ...IterateOption) error

func (*Manager) IsOutputUnspent

func (u *Manager) IsOutputUnspent(output *Output) (bool, error)

func (*Manager) MilestoneDiff

func (u *Manager) MilestoneDiff(msIndex milestone.Index) (*MilestoneDiff, error)

func (*Manager) ReadLedgerIndex

func (u *Manager) ReadLedgerIndex() milestone.Index

func (*Manager) ReadOutputByOutputID

func (u *Manager) ReadOutputByOutputID(outputID *iotago.UTXOInputID) (*Output, error)

func (*Manager) ReadSpentForOutput

func (u *Manager) ReadSpentForOutput(output *Output) (*Spent, error)

func (*Manager) ReadSpentForOutputID

func (u *Manager) ReadSpentForOutputID(outputID *iotago.UTXOInputID) (*Spent, error)

func (*Manager) SpentOutputs

func (u *Manager) SpentOutputs(options ...IterateOption) (Spents, error)

func (*Manager) UnspentOutputs

func (u *Manager) UnspentOutputs(options ...IterateOption) ([]*Output, error)

func (*Manager) UnspentTreasuryOutput

func (u *Manager) UnspentTreasuryOutput() (*TreasuryOutput, error)

UnspentTreasuryOutput returns the unspent treasury output.

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.

type Output

type Output struct {
	// contains filtered or unexported fields
}

func (*Output) Address

func (o *Output) Address() iotago.Address

func (*Output) AddressBytes

func (o *Output) AddressBytes() []byte

func (*Output) Amount

func (o *Output) Amount() uint64

func (*Output) MessageID

func (o *Output) MessageID() hornet.MessageID

func (*Output) OutputID

func (o *Output) OutputID() *iotago.UTXOInputID

func (*Output) OutputType

func (o *Output) OutputType() iotago.OutputType

type OutputConsumer

type OutputConsumer func(output *Output) bool

type Outputs

type Outputs []*Output

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) Address

func (s *Spent) Address() iotago.Address

func (*Spent) Amount

func (s *Spent) Amount() uint64

func (*Spent) ConfirmationIndex

func (s *Spent) ConfirmationIndex() milestone.Index

func (*Spent) MessageID

func (s *Spent) MessageID() hornet.MessageID

func (*Spent) Output

func (s *Spent) Output() *Output

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 SpentConsumer func(spent *Spent) bool

type Spents

type Spents []*Spent

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.

Jump to

Keyboard shortcuts

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