snapshot

package
v2.0.0-rc.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// AdditionalMilestoneDiffRange defines the maximum number of additional
	// milestone diffs that are stored in the full snapshot.
	// These are used to reconstruct pending protocol parameter updates.
	AdditionalMilestoneDiffRange syncmanager.MilestoneIndexDelta = 30
)
View Source
const (
	// SupportedFormatVersion defines the supported snapshot file version.
	SupportedFormatVersion byte = 2
)

Variables

View Source
var (
	// ErrUnsupportedSnapshot is returned when unsupported snapshot data is read.
	ErrUnsupportedSnapshot = errors.New("unsupported snapshot data")
	// ErrWrongMilestoneDiffIndex is returned when the milestone diff that should be applied is not the current or next milestone.
	ErrWrongMilestoneDiffIndex = errors.New("wrong milestone diff index")
	// ErrFinalLedgerIndexDoesNotMatchTargetIndex is returned when the final milestone after loading the snapshot is not equal to the target index.
	ErrFinalLedgerIndexDoesNotMatchTargetIndex = errors.New("final ledger index does not match target index")
	// ErrInvalidSnapshotAvailabilityState is returned when a delta snapshot is available, but no full snapshot is found.
	ErrInvalidSnapshotAvailabilityState = errors.New("invalid snapshot files availability")
	// ErrDeltaSnapshotIncompatible is returned when a delta snapshot file does not match full snapshot file.
	ErrDeltaSnapshotIncompatible = errors.New("delta snapshot file does not match full snapshot file")
	// ErrNoMoreSEPToProduce is returned when there are no more solid entry points to produce.
	ErrNoMoreSEPToProduce = errors.New("no more SEP to produce")

	ErrNoSnapshotSpecified           = errors.New("no snapshot file was specified in the config")
	ErrNoSnapshotDownloadURL         = errors.New("no download URL specified for snapshot files in config")
	ErrSnapshotDownloadWasAborted    = errors.New("snapshot download was aborted")
	ErrSnapshotDownloadNoValidSource = errors.New("no valid source found, snapshot download not possible")
	ErrSnapshotCreationWasAborted    = errors.New("operation was aborted")
	ErrSnapshotCreationFailed        = errors.New("creating snapshot failed")
	ErrTargetIndexTooNew             = errors.New("snapshot target is too new")
	ErrTargetIndexTooOld             = errors.New("snapshot target is too old")
	ErrNotEnoughHistory              = errors.New("not enough history")
)
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")
	// ErrOutputConsumerNotProvided is returned when an output consumer has not been provided.
	ErrOutputConsumerNotProvided = errors.New("output consumer 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")
	// ErrTreasuryOutputConsumerNotProvided is returned when a treasury output consumer has not been provided.
	ErrTreasuryOutputConsumerNotProvided = errors.New("treasury output consumer is not provided")
	// ErrSnapshotsNotMergeable is returned if specified snapshots are not mergeable.
	ErrSnapshotsNotMergeable = errors.New("snapshot files not mergeable")
	// ErrWrongSnapshotType is returned if the snapshot type is not supported by this function.
	ErrWrongSnapshotType = errors.New("wrong snapshot type")
)

Functions

func FormatSnapshotTimestamp

func FormatSnapshotTimestamp(timestamp uint32) string

func LoadSnapshotFilesToStorage

func LoadSnapshotFilesToStorage(ctx context.Context, dbStorage *storage.Storage, writeMilestonesToStorage bool, fullPath string, deltaPath ...string) (*FullSnapshotHeader, *DeltaSnapshotHeader, error)

LoadSnapshotFilesToStorage loads the snapshot files from the given file paths into the storage.

func MetricsCaller

func MetricsCaller(handler interface{}, params ...interface{})

MetricsCaller is used to signal updated snapshot metrics.

func NewMsIndexIterator

func NewMsIndexIterator(direction MsDiffDirection, ledgerIndex iotago.MilestoneIndex, targetIndex iotago.MilestoneIndex) func() (msIndex iotago.MilestoneIndex, done bool)

NewMsIndexIterator returns an iterator producing milestone indices with the given direction from/to the milestone range.

func ReadMilestoneDiffProtocolParameters

func ReadMilestoneDiffProtocolParameters(reader io.ReadSeeker, protocolStorage *storage.ProtocolStorage, ignoreIndex ...iotago.MilestoneIndex) (int64, error)

ReadMilestoneDiffProtocolParameters reads protocol parameter updates from a MilestoneDiff from the given reader. automatically seek to the end of the MilestoneDiff.

func ReadOutput

func ReadOutput(reader io.ReadSeeker, protoParams *iotago.ProtocolParameters) (*utxo.Output, error)

ReadOutput reads an Output from the given reader.

func ReadSnapshotHeaderFromFile

func ReadSnapshotHeaderFromFile(filePath string, headerConsumer func(readCloser io.ReadCloser) error) error

ReadSnapshotHeaderFromFile reads the header of the given snapshot file.

func StreamDeltaSnapshotDataFrom

func StreamDeltaSnapshotDataFrom(
	ctx context.Context,
	reader io.ReadSeeker,
	protocolStorageGetter ProtocolStorageGetterFunc,
	headerConsumer DeltaHeaderConsumerFunc,
	msDiffConsumer MilestoneDiffConsumerFunc,
	sepConsumer SEPConsumerFunc,
	protoParamsMsOptionsConsumer ProtocolParamsMilestoneOptConsumerFunc) error

StreamDeltaSnapshotDataFrom consumes a delta snapshot from the given reader.

func StreamFullSnapshotDataFrom

func StreamFullSnapshotDataFrom(
	ctx context.Context,
	reader io.ReadSeeker,
	headerConsumer FullHeaderConsumerFunc,
	unspentTreasuryOutputConsumer UnspentTreasuryOutputConsumerFunc,
	outputConsumer OutputConsumerFunc,
	msDiffConsumer MilestoneDiffConsumerFunc,
	sepConsumer SEPConsumerFunc,
	protoParamsMsOptionsConsumer ProtocolParamsMilestoneOptConsumerFunc) error

StreamFullSnapshotDataFrom consumes a full snapshot from the given reader.

Types

type DeltaHeaderConsumerFunc

type DeltaHeaderConsumerFunc func(h *DeltaSnapshotHeader) error

DeltaHeaderConsumerFunc consumes the delta snapshot file header. A returned error signals to cancel further reading.

type DeltaSnapshotHeader

type DeltaSnapshotHeader struct {
	// Version denotes the version of this snapshot.
	Version byte
	// Type denotes the type of this snapshot.
	Type Type
	// 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 target milestone of the full snapshot this delta snapshot builts up from.
	FullSnapshotTargetMilestoneID iotago.MilestoneID
	// The file offset of the SEPs field. This is used to easily update an existing delta snapshot without parsing its content.
	SEPFileOffset int64
	// The amount of milestone diffs contained within this snapshot.
	MilestoneDiffCount uint32
	// The amount of SEPs contained within this snapshot.
	SEPCount uint16
}

func ReadDeltaSnapshotHeader

func ReadDeltaSnapshotHeader(reader io.Reader) (*DeltaSnapshotHeader, error)

ReadDeltaSnapshotHeader reads the delta snapshot header from the given reader.

func ReadDeltaSnapshotHeaderFromFile

func ReadDeltaSnapshotHeaderFromFile(filePath string) (*DeltaSnapshotHeader, error)

ReadDeltaSnapshotHeaderFromFile reads the header of the given delta snapshot file.

type DownloadTarget

type DownloadTarget struct {
	// URL of the full snapshot file.
	Full string `usage:"URL of the full snapshot file" json:"full"`
	// URL of the delta snapshot file.
	Delta string `usage:"URL of the delta snapshot file" json:"delta"`
}

DownloadTarget holds URLs to a full and delta snapshot.

type Events

type Events struct {
	SnapshotMilestoneIndexChanged         *events.Event
	SnapshotMetricsUpdated                *events.Event
	HandledConfirmedMilestoneIndexChanged *events.Event
}

type FullHeaderConsumerFunc

type FullHeaderConsumerFunc func(h *FullSnapshotHeader) error

FullHeaderConsumerFunc consumes the full snapshot file header. A returned error signals to cancel further reading.

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 *utxo.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
}

func CreateSnapshotFromStorage

func CreateSnapshotFromStorage(
	ctx context.Context,
	dbStorage *storage.Storage,
	utxoManager *utxo.Manager,
	filePath string,
	targetIndex iotago.MilestoneIndex,
	globalSnapshot bool,
	solidEntryPointCheckThresholdPast iotago.MilestoneIndex,
	solidEntryPointCheckThresholdFuture iotago.MilestoneIndex,
) (*FullSnapshotHeader, error)

CreateSnapshotFromStorage creates a snapshot file by streaming data from the database into a snapshot file.

func ReadFullSnapshotHeader

func ReadFullSnapshotHeader(reader io.Reader) (*FullSnapshotHeader, error)

ReadFullSnapshotHeader reads the full snapshot header from the given reader.

func ReadFullSnapshotHeaderFromFile

func ReadFullSnapshotHeaderFromFile(filePath string) (*FullSnapshotHeader, error)

ReadFullSnapshotHeaderFromFile reads the header of the given full snapshot file.

func (*FullSnapshotHeader) ProtocolParameters

func (h *FullSnapshotHeader) ProtocolParameters() (*iotago.ProtocolParameters, error)

type Importer

type Importer struct {
	// the logger used to log events.
	*logger.WrappedLogger
	// contains filtered or unexported fields
}

func NewSnapshotImporter

func NewSnapshotImporter(
	log *logger.Logger,
	storage *storage.Storage,
	snapshotFullPath string,
	snapshotDeltaPath string,
	targetNetworkName string,
	downloadTargets []*DownloadTarget) *Importer

NewSnapshotImporter creates a new snapshot manager instance.

func (*Importer) DownloadSnapshotFiles

func (s *Importer) DownloadSnapshotFiles(ctx context.Context, targetNetworkID uint64, fullPath string, deltaPath string, targets []*DownloadTarget) error

DownloadSnapshotFiles tries to download snapshots files from the given targets.

func (*Importer) ImportSnapshots

func (s *Importer) ImportSnapshots(ctx context.Context) error

ImportSnapshots imports snapshot data from the configured file paths. automatically downloads snapshot data if no files are available.

func (*Importer) LoadDeltaSnapshotFromFile

func (s *Importer) LoadDeltaSnapshotFromFile(ctx context.Context, filePath string) (err error)

LoadDeltaSnapshotFromFile loads a snapshot file from the given file path into the storage.

func (*Importer) LoadFullSnapshotFromFile

func (s *Importer) LoadFullSnapshotFromFile(ctx context.Context, filePath string, targetNetworkID iotago.NetworkID) (err error)

LoadFullSnapshotFromFile loads a snapshot file from the given file path into the storage.

func (*Importer) SnapshotsFilesLedgerIndex

func (s *Importer) SnapshotsFilesLedgerIndex() (iotago.MilestoneIndex, error)

SnapshotsFilesLedgerIndex returns the final ledger index if the snapshots from the configured file paths would be applied.

type Manager

type Manager struct {
	// the logger used to log events.
	*logger.WrappedLogger

	Events *Events
	// contains filtered or unexported fields
}

Manager handles reading and writing snapshot data.

func NewSnapshotManager

func NewSnapshotManager(
	log *logger.Logger,
	storage *storagepkg.Storage,
	syncManager *syncmanager.SyncManager,
	utxoManager *utxo.Manager,
	snapshotCreationEnabled bool,
	snapshotFullPath string,
	snapshotDeltaPath string,
	deltaSnapshotSizeThresholdPercentage float64,
	deltaSnapshotSizeThresholdMinSizeBytes int64,
	solidEntryPointCheckThresholdPast syncmanager.MilestoneIndexDelta,
	solidEntryPointCheckThresholdFuture syncmanager.MilestoneIndexDelta,
	snapshotDepth syncmanager.MilestoneIndexDelta,
	snapshotInterval iotago.MilestoneIndex,
) *Manager

NewSnapshotManager creates a new snapshot manager instance.

func (*Manager) CreateFullSnapshot

func (s *Manager) CreateFullSnapshot(ctx context.Context, targetIndex iotago.MilestoneIndex, filePath string, writeToDatabase bool) error

CreateFullSnapshot creates a full snapshot for the given target milestone index.

func (*Manager) HandleNewConfirmedMilestoneEvent

func (s *Manager) HandleNewConfirmedMilestoneEvent(ctx context.Context, confirmedMilestoneIndex iotago.MilestoneIndex)

HandleNewConfirmedMilestoneEvent handles new confirmed milestone events which may trigger a snapshot creation.

func (*Manager) IsSnapshotting

func (s *Manager) IsSnapshotting() bool

func (*Manager) MinimumMilestoneIndex

func (s *Manager) MinimumMilestoneIndex() iotago.MilestoneIndex

type MergeInfo

type MergeInfo struct {
	// The header of the full snapshot.
	FullSnapshotHeader *FullSnapshotHeader
	// The header of the delta snapshot.
	DeltaSnapshotHeader *DeltaSnapshotHeader
	// The header of the merged snapshot.
	MergedSnapshotHeader *FullSnapshotHeader
}

MergeInfo holds information about a merge of a full and delta snapshot.

func MergeSnapshotsFiles

func MergeSnapshotsFiles(ctx context.Context, fullPath string, deltaPath string, targetFileName string) (*MergeInfo, error)

MergeSnapshotsFiles merges the given full and delta snapshots to create an updated full snapshot. The result is a full snapshot file containing the ledger outputs corresponding to the snapshot index of the specified delta snapshot. The target file does not include any milestone diffs and the ledger and snapshot index are equal. This function consumes disk space over memory by importing the full snapshot into a temporary database, applying the delta diffs onto it and then writing out the merged state.

type Metrics

type Metrics struct {
	DurationReadLockLedger                time.Duration
	DurationInit                          time.Duration
	DurationSetSnapshotInfo               time.Duration
	DurationSnapshotMilestoneIndexChanged time.Duration
	DurationHeader                        time.Duration
	DurationSolidEntryPoints              time.Duration
	DurationOutputs                       time.Duration
	DurationMilestoneDiffs                time.Duration
	DurationTotal                         time.Duration
}

Metrics holds metrics about a snapshot creation run.

func StreamDeltaSnapshotDataTo

func StreamDeltaSnapshotDataTo(
	writeSeeker io.WriteSeeker,
	header *DeltaSnapshotHeader,
	msDiffProd MilestoneDiffProducerFunc,
	sepProd SEPProducerFunc) (*Metrics, error)

StreamDeltaSnapshotDataTo streams delta snapshot data into the given io.WriteSeeker.

func StreamDeltaSnapshotDataToExisting

func StreamDeltaSnapshotDataToExisting(
	fileHandle ReadWriteTruncateSeeker,
	header *DeltaSnapshotHeader,
	msDiffProd MilestoneDiffProducerFunc,
	sepProd SEPProducerFunc) (*Metrics, error)

StreamDeltaSnapshotDataToExisting updates a delta snapshot and streams data into the given io.WriteSeeker.

func StreamFullSnapshotDataTo

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

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

type MilestoneDiff

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

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

func ReadMilestoneDiff

func ReadMilestoneDiff(reader io.ReadSeeker, protocolStorage *storage.ProtocolStorage, addProtocolParameterUpdates bool) (int64, *MilestoneDiff, error)

ReadMilestoneDiff reads a MilestoneDiff from the given reader.

func (*MilestoneDiff) MarshalBinary

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

func (*MilestoneDiff) TreasuryOutput

func (md *MilestoneDiff) TreasuryOutput() *utxo.TreasuryOutput

TreasuryOutput extracts the new treasury output from within the milestone receipt. Might return nil if there is no receipt within the milestone.

type MilestoneDiffConsumerFunc

type MilestoneDiffConsumerFunc func(milestoneDiff *MilestoneDiff) error

MilestoneDiffConsumerFunc consumes the given MilestoneDiff. A returned error signals to cancel further reading.

func NewMsDiffConsumer

func NewMsDiffConsumer(dbStorage *storage.Storage, utxoManager *utxo.Manager, writeMilestonesToStorage bool) MilestoneDiffConsumerFunc

NewMsDiffConsumer creates a milestone diff consumer storing them into the database. if the ledger index within the database equals the produced milestone diff's index, then its changes are roll-backed, otherwise, if the index is higher than the ledger index, its mutations are applied on top of the latest state. the caller needs to make sure to set the ledger index accordingly beforehand.

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.

func NewMsDiffsProducer

func NewMsDiffsProducer(mrf MilestoneRetrieverFunc, utxoManager *utxo.Manager, direction MsDiffDirection, ledgerMilestoneIndex iotago.MilestoneIndex, targetIndex iotago.MilestoneIndex) MilestoneDiffProducerFunc

NewMsDiffsProducer returns a producer which produces milestone diffs from/to with the given direction.

type MilestoneRetrieverFunc

type MilestoneRetrieverFunc func(index iotago.MilestoneIndex) (*iotago.Milestone, error)

MilestoneRetrieverFunc is a function which returns the milestone for the given index.

func MilestoneRetrieverFromStorage

func MilestoneRetrieverFromStorage(dbStorage *storage.Storage) MilestoneRetrieverFunc

MilestoneRetrieverFromStorage creates a MilestoneRetrieverFunc which access the storage. If it can not retrieve a wanted milestone it panics.

type MsDiffDirection

type MsDiffDirection byte

MsDiffDirection determines the milestone diff direction.

const (
	// MsDiffDirectionBackwards defines to produce milestone diffs in backwards direction.
	MsDiffDirectionBackwards MsDiffDirection = iota
	// MsDiffDirectionOnwards defines to produce milestone diffs in onwards direction.
	MsDiffDirectionOnwards
)

type OutputConsumerFunc

type OutputConsumerFunc func(output *utxo.Output) error

OutputConsumerFunc consumes the given output. A returned error signals to cancel further reading.

func NewOutputConsumer

func NewOutputConsumer(utxoManager *utxo.Manager) OutputConsumerFunc

NewOutputConsumer returns an output consumer storing them into the database.

type OutputProducerFunc

type OutputProducerFunc func() (*utxo.Output, error)

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

func NewCMIUTXOProducer

func NewCMIUTXOProducer(utxoManager *utxo.Manager) OutputProducerFunc

NewCMIUTXOProducer returns a producer which produces unspent outputs which exist for the current confirmed milestone.

type ProtocolParamsMilestoneOptConsumerFunc

type ProtocolParamsMilestoneOptConsumerFunc func(*iotago.ProtocolParamsMilestoneOpt) error

ProtocolParamsMilestoneOptConsumerFunc consumes the given ProtocolParamsMilestoneOpt. A returned error signals to cancel further reading.

type ProtocolStorageGetterFunc

type ProtocolStorageGetterFunc func() (*storage.ProtocolStorage, error)

ProtocolStorageGetterFunc returns a ProtocolStorage.

type ReadWriteTruncateSeeker

type ReadWriteTruncateSeeker interface {
	io.ReadWriteSeeker
	Truncate(size int64) error
}

ReadWriteTruncateSeeker is the interface used to read, write and truncate a file.

type SEPConsumerFunc

type SEPConsumerFunc func(iotago.BlockID, iotago.MilestoneIndex) error

SEPConsumerFunc consumes the given solid entry point. A returned error signals to cancel further reading.

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.

func NewSEPsProducer

func NewSEPsProducer(
	ctx context.Context,
	dbStorage *storage.Storage,
	targetIndex iotago.MilestoneIndex,
	solidEntryPointCheckThresholdPast iotago.MilestoneIndex) SEPProducerFunc

NewSEPsProducer returns a producer which produces solid entry points.

func NewSEPsProducerFromMilestone

func NewSEPsProducerFromMilestone(milestonePayload *iotago.Milestone) SEPProducerFunc

NewSEPsProducerFromMilestone returns a producer which produces the parents of a milestone as solid entry points.

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
	// Delta is a snapshot which contains solely diffs of milestones newer than a certain ledger milestone
	// instead of the complete ledger state of a given milestone.
	// the delta snapshot contains no additional milestone diffs to calculate the correct protocol parameters,
	// because they are already included in the full snapshot.
	Delta
)

func ReadSnapshotType

func ReadSnapshotType(readSeeker io.ReadSeeker) (Type, error)

ReadSnapshotType reads the snapshot type from the given reader.

func ReadSnapshotTypeFromFile

func ReadSnapshotTypeFromFile(filePath string) (Type, error)

ReadSnapshotTypeFromFile reads the snapshot type of the given snapshot file.

type UnspentTreasuryOutputConsumerFunc

type UnspentTreasuryOutputConsumerFunc func(output *utxo.TreasuryOutput) error

UnspentTreasuryOutputConsumerFunc consumes the given treasury output. A returned error signals to cancel further reading.

func NewUnspentTreasuryOutputConsumer

func NewUnspentTreasuryOutputConsumer(utxoManager *utxo.Manager) UnspentTreasuryOutputConsumerFunc

NewUnspentTreasuryOutputConsumer returns a treasury output consumer which overrides an existing unspent treasury output with the new one.

type WriteCounter

type WriteCounter struct {
	Expected uint64
	// contains filtered or unexported fields
}

WriteCounter counts the number of bytes written to it. It implements to the io.Writer interface and we can pass this into io.TeeReader() which will report progress on each write cycle.

func NewWriteCounter

func NewWriteCounter(ctx context.Context, expected uint64) *WriteCounter

NewWriteCounter creates a new WriteCounter.

func (*WriteCounter) PrintProgress

func (wc *WriteCounter) PrintProgress()

PrintProgress prints the current progress.

func (*WriteCounter) Write

func (wc *WriteCounter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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