Documentation ¶
Index ¶
Constants ¶
const ( // SensibleMaxEntriesCount defines an amount of entries within receipts which allows a milestone with 8 parents and 2 sigs/pub keys // to fly under the next pow requirement step. SensibleMaxEntriesCount = 110 )
Variables ¶
var ( // ErrStateFileAlreadyExists is returned when a new state is tried to be initialized but a state file already exists. ErrStateFileAlreadyExists = errors.New("migrator state file already exists") // ErrInvalidState is returned when the content of the state file is invalid. ErrInvalidState = errors.New("invalid migrator state") )
Functions ¶
func MigratedFundsCaller ¶
func MigratedFundsCaller(handler interface{}, params ...interface{})
MigratedFundsCaller is an event caller which gets migrated funds passed.
Types ¶
type MigratorService ¶
type MigratorService struct { Events *MigratorServiceEvents // contains filtered or unexported fields }
MigratorService is a service querying and validating batches of migrated funds.
func NewService ¶
func NewService(queryer Queryer, stateFilePath string, receiptMaxEntries int) *MigratorService
NewService creates a new MigratorService.
func (*MigratorService) InitState ¶
func (s *MigratorService) InitState(msIndex *iotago.MilestoneIndex) error
InitState initializes the state of s. If msIndex is not nil, s is bootstrapped using that index as its initial state, otherwise the state is loaded from file. The optional utxoManager is used to validate the initialized state against the DB. InitState must be called before Start.
func (*MigratorService) PersistState ¶
func (s *MigratorService) PersistState(sendingReceipt bool) error
PersistState persists the current state to a file. PersistState must be called when the receipt returned by the last call of Receipt has been send to the network.
func (*MigratorService) Receipt ¶
func (s *MigratorService) Receipt() *iotago.ReceiptMilestoneOpt
Receipt returns the next receipt of migrated funds. Each receipt can only consists of migrations confirmed by one milestone, it will never be larger than MaxMigratedFundsEntryCount. Receipt returns nil, if there are currently no new migrations available. Although the actual API calls and validations happen in the background, Receipt might block until the next receipt is ready. When s is stopped, Receipt will always return nil.
func (*MigratorService) Start ¶
func (s *MigratorService) Start(ctx context.Context, onError OnServiceErrorFunc)
Start stats the MigratorService s, it stops when the given context is done.
type MigratorServiceEvents ¶
type MigratorServiceEvents struct { // SoftError is triggered when a soft error is encountered. SoftError *events.Event // MigratedFundsFetched is triggered when new migration funds were fetched from a legacy node. MigratedFundsFetched *events.Event }
MigratorServiceEvents are events happening around a MigratorService.
type OnServiceErrorFunc ¶
OnServiceErrorFunc is a function which is called when the service encounters an error which prevents it from functioning properly. Returning false from the error handler tells the service to terminate.
type Queryer ¶
type Queryer interface { QueryMigratedFunds(iotago.MilestoneIndex) ([]*iotago.MigratedFundsEntry, error) QueryNextMigratedFunds(iotago.MilestoneIndex) (iotago.MilestoneIndex, []*iotago.MigratedFundsEntry, error) }
Queryer defines the interface used to query the migrated funds.