Documentation
¶
Overview ¶
Package workers implements the attestation worker for the payer report.
Index ¶
- type AttestationWorker
- type GeneratorWorker
- type SettlementWorker
- type SubmitterWorker
- type WorkerConfigBuilder
- func (b *WorkerConfigBuilder) Build() (*workerConfig, error)
- func (b *WorkerConfigBuilder) WithAttestationPollInterval(interval time.Duration) *WorkerConfigBuilder
- func (b *WorkerConfigBuilder) WithContext(ctx context.Context) *WorkerConfigBuilder
- func (b *WorkerConfigBuilder) WithDomainSeparator(domainSeparator common.Hash) *WorkerConfigBuilder
- func (b *WorkerConfigBuilder) WithExpiryOthersPeriod(period time.Duration) *WorkerConfigBuilder
- func (b *WorkerConfigBuilder) WithExpirySelfPeriod(period time.Duration) *WorkerConfigBuilder
- func (b *WorkerConfigBuilder) WithGenerationOthersPeriod(period time.Duration) *WorkerConfigBuilder
- func (b *WorkerConfigBuilder) WithGenerationSelfPeriod(period time.Duration) *WorkerConfigBuilder
- func (b *WorkerConfigBuilder) WithLogger(logger *zap.Logger) *WorkerConfigBuilder
- func (b *WorkerConfigBuilder) WithRegistrant(registrant registrant.IRegistrant) *WorkerConfigBuilder
- func (b *WorkerConfigBuilder) WithRegistry(registry registry.NodeRegistry) *WorkerConfigBuilder
- func (b *WorkerConfigBuilder) WithReportsManager(reportsManager blockchain.PayerReportsManager) *WorkerConfigBuilder
- func (b *WorkerConfigBuilder) WithStore(store payerreport.IPayerReportStore) *WorkerConfigBuilder
- type WorkerWrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttestationWorker ¶
type AttestationWorker struct {
// contains filtered or unexported fields
}
AttestationWorker is responsible for periodically checking for reports that need attestation and signing them with the node's private key.
func NewAttestationWorker ¶
func NewAttestationWorker( ctx context.Context, logger *zap.Logger, registrant registrant.IRegistrant, store payerreport.IPayerReportStore, pollInterval time.Duration, domainSeparator common.Hash, ) *AttestationWorker
NewAttestationWorker creates and starts a new attestation worker that will periodically check for reports that need attestation. It takes a context, logger, registrant for signing, store for accessing reports, and a poll interval that determines how often to check for reports.
func (*AttestationWorker) AttestReports ¶
func (w *AttestationWorker) AttestReports() error
AttestReports fetches all reports with pending attestation status and attempts to attest each one. Returns an error if there was a problem fetching the reports.
func (*AttestationWorker) Start ¶
func (w *AttestationWorker) Start()
Start launches the worker's main loop in a separate goroutine. The loop periodically checks for reports that need attestation.
func (*AttestationWorker) Stop ¶
func (w *AttestationWorker) Stop()
type GeneratorWorker ¶
type GeneratorWorker struct {
// contains filtered or unexported fields
}
func NewGeneratorWorker ¶
func NewGeneratorWorker( ctx context.Context, logger *zap.Logger, store payerreport.IPayerReportStore, registry registry.NodeRegistry, registrant registrant.IRegistrant, domainSeparator common.Hash, generateSelfPeriod time.Duration, generateOthersPeriod time.Duration, expirySelfPeriod time.Duration, expiryOthersPeriod time.Duration, ) *GeneratorWorker
func (*GeneratorWorker) GenerateReports ¶
func (w *GeneratorWorker) GenerateReports() error
func (*GeneratorWorker) Start ¶
func (w *GeneratorWorker) Start()
func (*GeneratorWorker) Stop ¶
func (w *GeneratorWorker) Stop()
type SettlementWorker ¶ added in v1.0.0
type SettlementWorker struct {
// contains filtered or unexported fields
}
func NewSettlementWorker ¶ added in v1.0.0
func NewSettlementWorker( ctx context.Context, logger *zap.Logger, payerReportStore payerreport.IPayerReportStore, verifier payerreport.IPayerReportVerifier, reportManager blockchain.PayerReportsManager, myNodeID uint32, ) *SettlementWorker
func (*SettlementWorker) SettleReports ¶ added in v1.0.0
func (w *SettlementWorker) SettleReports(ctx context.Context) error
func (*SettlementWorker) Start ¶ added in v1.0.0
func (w *SettlementWorker) Start()
func (*SettlementWorker) Stop ¶ added in v1.0.0
func (w *SettlementWorker) Stop()
type SubmitterWorker ¶
type SubmitterWorker struct {
// contains filtered or unexported fields
}
func NewSubmitterWorker ¶
func NewSubmitterWorker( ctx context.Context, logger *zap.Logger, payerReportStore payerreport.IPayerReportStore, registry registry.NodeRegistry, reportsManager blockchain.PayerReportsManager, myNodeID uint32, ) *SubmitterWorker
func (*SubmitterWorker) Start ¶
func (w *SubmitterWorker) Start()
func (*SubmitterWorker) Stop ¶
func (w *SubmitterWorker) Stop()
func (*SubmitterWorker) SubmitReports ¶
func (w *SubmitterWorker) SubmitReports(ctx context.Context) error
SubmitReports is the main loop of the submitter worker. The submitter worker fetches all reports that are pending submission and approved attestation. Note: All reports are fetched independently of the originator node ID. This means the submitter:
- will try to submit reports for other nodes if they are pending submission and approved attestation.
- works on a loop that gets activated every `findNextRunTime(originatorNodeID, submitterWorkerID)` minutes. this distribution guarantees that no two nodes will submit reports for the same originator node at the same time. the blockchain guarantees deduplication of report submissions.
- even with `findNextRunTime` the system has to guarantee that no duplicates are submitted.
type WorkerConfigBuilder ¶ added in v1.0.0
type WorkerConfigBuilder struct {
// contains filtered or unexported fields
}
WorkerConfigBuilder provides a builder pattern for creating WorkerConfig instances. All fields are required and the Build() method will validate that none are nil.
func NewWorkerConfigBuilder ¶ added in v1.0.0
func NewWorkerConfigBuilder() *WorkerConfigBuilder
NewWorkerConfigBuilder creates a new WorkerConfigBuilder instance.
func (*WorkerConfigBuilder) Build ¶ added in v1.0.0
func (b *WorkerConfigBuilder) Build() (*workerConfig, error)
Build creates a WorkerConfig instance after validating that all required fields are set. Returns an error if any required field is nil or invalid.
func (*WorkerConfigBuilder) WithAttestationPollInterval ¶ added in v1.0.0
func (b *WorkerConfigBuilder) WithAttestationPollInterval( interval time.Duration, ) *WorkerConfigBuilder
func (*WorkerConfigBuilder) WithContext ¶ added in v1.0.0
func (b *WorkerConfigBuilder) WithContext(ctx context.Context) *WorkerConfigBuilder
func (*WorkerConfigBuilder) WithDomainSeparator ¶ added in v1.0.0
func (b *WorkerConfigBuilder) WithDomainSeparator( domainSeparator common.Hash, ) *WorkerConfigBuilder
func (*WorkerConfigBuilder) WithExpiryOthersPeriod ¶ added in v1.0.0
func (b *WorkerConfigBuilder) WithExpiryOthersPeriod( period time.Duration, ) *WorkerConfigBuilder
func (*WorkerConfigBuilder) WithExpirySelfPeriod ¶ added in v1.0.0
func (b *WorkerConfigBuilder) WithExpirySelfPeriod( period time.Duration, ) *WorkerConfigBuilder
func (*WorkerConfigBuilder) WithGenerationOthersPeriod ¶ added in v1.0.0
func (b *WorkerConfigBuilder) WithGenerationOthersPeriod( period time.Duration, ) *WorkerConfigBuilder
func (*WorkerConfigBuilder) WithGenerationSelfPeriod ¶ added in v1.0.0
func (b *WorkerConfigBuilder) WithGenerationSelfPeriod( period time.Duration, ) *WorkerConfigBuilder
func (*WorkerConfigBuilder) WithLogger ¶ added in v1.0.0
func (b *WorkerConfigBuilder) WithLogger(logger *zap.Logger) *WorkerConfigBuilder
func (*WorkerConfigBuilder) WithRegistrant ¶ added in v1.0.0
func (b *WorkerConfigBuilder) WithRegistrant( registrant registrant.IRegistrant, ) *WorkerConfigBuilder
func (*WorkerConfigBuilder) WithRegistry ¶ added in v1.0.0
func (b *WorkerConfigBuilder) WithRegistry(registry registry.NodeRegistry) *WorkerConfigBuilder
func (*WorkerConfigBuilder) WithReportsManager ¶ added in v1.0.0
func (b *WorkerConfigBuilder) WithReportsManager( reportsManager blockchain.PayerReportsManager, ) *WorkerConfigBuilder
func (*WorkerConfigBuilder) WithStore ¶ added in v1.0.0
func (b *WorkerConfigBuilder) WithStore(store payerreport.IPayerReportStore) *WorkerConfigBuilder
type WorkerWrapper ¶ added in v1.0.0
type WorkerWrapper struct {
// contains filtered or unexported fields
}
func RunWorkers ¶ added in v1.0.0
func RunWorkers(cfg workerConfig) *WorkerWrapper
RunWorkers creates and starts all payer report workers with the given configuration. The configuration should be created using NewWorkerConfigBuilder().Build(). Returns a WorkerWrapper that can be used to stop all workers.
func (*WorkerWrapper) Stop ¶ added in v1.0.0
func (w *WorkerWrapper) Stop()