Documentation ¶
Index ¶
- Constants
- Variables
- func StreamFullSnapshotDataTo(writeSeeker io.WriteSeeker, header *FullSnapshotHeader, ...) error
- type FullSnapshotHeader
- type MilestoneDiff
- type MilestoneDiffProducerFunc
- type Output
- type OutputProducerFunc
- type Outputs
- type SEPProducerFunc
- type Spent
- type Spents
- type TreasuryOutput
- type Type
Constants ¶
const ( // SupportedFormatVersion defines the supported snapshot file version. SupportedFormatVersion byte = 2 )
Variables ¶
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 (*Output) SnapshotBytes ¶
type OutputProducerFunc ¶
OutputProducerFunc yields an output to be written to a snapshot or nil if no more is available.
type SEPProducerFunc ¶
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) SnapshotBytes ¶
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 )