migrator

package
v2.0.0-rc.7 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyBundle = errors.New("empty bundle")

ErrEmptyBundle is returned when a bundle contains no transaction.

View Source
var (
	// ErrInvalidReceiptServiceState is returned when the state of the ReceiptService is invalid.
	ErrInvalidReceiptServiceState = errors.New("invalid receipt service state")
)

Functions

This section is empty.

Types

type LegacyAPI

type LegacyAPI interface {
	GetNodeInfo() (*api.GetNodeInfoResponse, error)
	GetWhiteFlagConfirmation(msIndex iotago.MilestoneIndex) (*api.WhiteFlagConfirmation, error)
}

LegacyAPI defines the calls of the legacy API that are used.

type ReceiptPersistFunc

type ReceiptPersistFunc func(r *iotago.ReceiptMilestoneOpt) error

ReceiptPersistFunc is a function which persists a receipt.

type ReceiptService

type ReceiptService struct {
	// Whether the service is configured to back up receipts.
	BackupEnabled bool
	// Whether the service is configured to validate receipts.
	ValidationEnabled bool
	// Whether the service should ignore soft errors.
	IgnoreSoftErrors bool
	// contains filtered or unexported fields
}

ReceiptService is in charge of persisting and validating a batch of receipts.

func NewReceiptService

func NewReceiptService(validator *Validator, utxoManager *utxo.Manager, validationEnabled bool, backupEnabled bool, ignoreSoftErrors bool, backupFolder string) *ReceiptService

NewReceiptService creates a new ReceiptService.

func (*ReceiptService) Backup

func (rs *ReceiptService) Backup(r *utxo.ReceiptTuple) error

Backup backups the given receipt to disk.

func (*ReceiptService) Init

func (rs *ReceiptService) Init() error

Init initializes the ReceiptService and returns the amount of receipts currently stored.

func (*ReceiptService) ValidateWithoutLocking

func (rs *ReceiptService) ValidateWithoutLocking(r *iotago.ReceiptMilestoneOpt) error

ValidateWithoutLocking validates the given receipt against data fetched from a legacy node. The UTXO ledger should be locked outside of this function. If the receipt has the final flag set to true, then the entire batch of receipts with the same migrated_at index are collected and it is checked whether they migrated all the funds of the given white-flag confirmation.

type ReceiptValidateFunc

type ReceiptValidateFunc func(r *iotago.ReceiptMilestoneOpt) error

ReceiptValidateFunc is a function which validates a receipt.

type Validator

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

Validator takes care of fetching and validating white-flag confirmation data from legacy nodes and wrapping them into receipts.

func NewValidator

func NewValidator(api LegacyAPI, coordinatorAddress trinary.Hash, coordinatorMerkleTreeDepth int) *Validator

NewValidator creates a new Validator.

func (*Validator) QueryMigratedFunds

func (m *Validator) QueryMigratedFunds(msIndex iotago.MilestoneIndex) ([]*iotago.MigratedFundsEntry, error)

QueryMigratedFunds queries the legacy network for the white-flag confirmation data for the given milestone index, verifies the signatures of the milestone and included bundles and then compiles a slice of migrated fund entries.

func (*Validator) QueryNextMigratedFunds

func (m *Validator) QueryNextMigratedFunds(startIndex iotago.MilestoneIndex) (iotago.MilestoneIndex, []*iotago.MigratedFundsEntry, error)

QueryNextMigratedFunds queries the next existing migrations starting from milestone index startIndex. It returns the migrations as well as milestone index that confirmed those migrations. If there are currently no more migrations, it returns the latest milestone index that was checked.

Jump to

Keyboard shortcuts

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