stardust

package
v0.0.0-...-6233654 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SupportedFormatVersion defines the supported snapshot file version.
	SupportedFormatVersion byte = 2
)

Variables

View Source
var (
	// ErrMilestoneDiffProducerNotProvided is returned when a milestone diff producer has not been provided.
	ErrMilestoneDiffProducerNotProvided = errors.New("milestone diff producer is not provided")
	// ErrSolidEntryPointProducerNotProvided is returned when a solid entry point producer has not been provided.
	ErrSolidEntryPointProducerNotProvided = errors.New("solid entry point producer is not provided")
	// ErrOutputProducerNotProvided is returned when an output producer has not been provided.
	ErrOutputProducerNotProvided = errors.New("output producer is not provided")
	// ErrTreasuryOutputNotProvided is returned when the treasury output for a full snapshot has not been provided.
	ErrTreasuryOutputNotProvided = errors.New("treasury output is not provided")
	// ErrWrongSnapshotType is returned if the snapshot type is not supported by this function.
	ErrWrongSnapshotType = errors.New("wrong snapshot type")
	// ErrNoMoreSEPToProduce is returned when there are no more solid entry points to produce.
	ErrNoMoreSEPToProduce = errors.New("no more SEP to produce")
)

Functions

func StreamFullSnapshotDataTo

func StreamFullSnapshotDataTo(
	writeSeeker io.WriteSeeker,
	header *FullSnapshotHeader,
	outputProd OutputProducerFunc,
	msDiffProd MilestoneDiffProducerFunc,
	sepProd SEPProducerFunc) error

StreamFullSnapshotDataTo streams a full snapshot data into the given io.WriteSeeker. This function modifies the counts in the FullSnapshotHeader.

Types

type FullSnapshotHeader

type FullSnapshotHeader struct {
	// Version denotes the version of this snapshot.
	Version byte
	// Type denotes the type of this snapshot.
	Type Type
	// The index of the genesis milestone of the network.
	GenesisMilestoneIndex iotago.MilestoneIndex
	// The index of the milestone of which the SEPs within the snapshot are from.
	TargetMilestoneIndex iotago.MilestoneIndex
	// The timestamp of the milestone of which the SEPs within the snapshot are from.
	TargetMilestoneTimestamp uint32
	// The ID of the milestone of which the SEPs within the snapshot are from.
	TargetMilestoneID iotago.MilestoneID
	// The index of the milestone of which the UTXOs within the snapshot are from.
	LedgerMilestoneIndex iotago.MilestoneIndex
	// The treasury output existing for the given ledger milestone index.
	// This field must be populated if a Full snapshot is created/read.
	TreasuryOutput *TreasuryOutput
	// Active Protocol Parameter of the ledger milestone index.
	ProtocolParamsMilestoneOpt *iotago.ProtocolParamsMilestoneOpt
	// The amount of UTXOs contained within this snapshot.
	OutputCount uint64
	// The amount of milestone diffs contained within this snapshot.
	MilestoneDiffCount uint32
	// The amount of SEPs contained within this snapshot.
	SEPCount uint16
}

type MilestoneDiff

type MilestoneDiff struct {
	// The milestone payload itself.
	Milestone *iotago.Milestone
	// The created outputs with this milestone.
	Created Outputs
	// The consumed spents with this milestone.
	Consumed Spents
	// The consumed treasury output with this milestone.
	SpentTreasuryOutput *TreasuryOutput
}

MilestoneDiff represents the outputs which were created and consumed for the given milestone and the block itself which contains the milestone.

func (*MilestoneDiff) MarshalBinary

func (md *MilestoneDiff) MarshalBinary() ([]byte, error)

type MilestoneDiffProducerFunc

type MilestoneDiffProducerFunc func() (*MilestoneDiff, error)

MilestoneDiffProducerFunc yields a milestone diff to be written to a snapshot or nil if no more is available.

type Output

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

func CreateOutput

func CreateOutput(outputID iotago.OutputID, blockID iotago.BlockID, msIndexBooked iotago.MilestoneIndex, msTimestampBooked uint32, output iotago.Output) *Output

func (*Output) Deposit

func (o *Output) Deposit() uint64

func (*Output) Output

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

func (*Output) SnapshotBytes

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

type OutputProducerFunc

type OutputProducerFunc func() (*Output, error)

OutputProducerFunc yields an output to be written to a snapshot or nil if no more is available.

type Outputs

type Outputs []*Output

type SEPProducerFunc

type SEPProducerFunc func() (iotago.BlockID, error)

SEPProducerFunc yields a solid entry point to be written to a snapshot or nil if no more is available.

type Spent

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

Spent are already spent TXOs (transaction outputs).

func (*Spent) Output

func (s *Spent) Output() *Output

func (*Spent) SnapshotBytes

func (s *Spent) SnapshotBytes() []byte

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.

type Type

type Type byte

Type defines the type of the snapshot.

const (
	// Full is a snapshot which contains the full ledger entry for a given milestone
	// plus the milestone diffs which subtracted to the ledger milestone reduce to the target milestone ledger.
	// the full snapshot contains additional milestone diffs to calculate the correct protocol parameters (before the target index).
	Full Type = iota
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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