aggsender

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AutomaticBlockInterval = time.Second * 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AggSender

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

AggSender is a component that will send certificates to the aggLayer

func New

func New(
	ctx context.Context,
	logger *log.Logger,
	cfg Config,
	aggLayerClient agglayer.AgglayerClientInterface,
	l1InfoTreeSyncer *l1infotreesync.L1InfoTreeSync,
	l2Syncer types.L2BridgeSyncer,
	epochNotifier types.EpochNotifier) (*AggSender, error)

New returns a new AggSender

func (*AggSender) Start

func (a *AggSender) Start(ctx context.Context)

Start starts the AggSender

type BlockNotifierPolling

type BlockNotifierPolling struct {
	types.GenericSubscriber[types.EventNewBlock]
	// contains filtered or unexported fields
}

func NewBlockNotifierPolling

func NewBlockNotifierPolling(ethClient types.EthClient,
	config ConfigBlockNotifierPolling,
	logger types.Logger,
	subscriber types.GenericSubscriber[types.EventNewBlock]) (*BlockNotifierPolling, error)

NewBlockNotifierPolling creates a new BlockNotifierPolling. if param `subscriber` is nil a new GenericSubscriberImpl[types.EventNewBlock] will be created. To use this class you need to subscribe and each time that a new block appear the subscriber will be notified through the channel. (check unit tests TestExploratoryBlockNotifierPolling for more information)

func (*BlockNotifierPolling) Start

func (b *BlockNotifierPolling) Start(ctx context.Context)

Start starts the BlockNotifierPolling blocking the current goroutine

func (*BlockNotifierPolling) String

func (b *BlockNotifierPolling) String() string

type Config

type Config struct {
	// StoragePath is the path of the sqlite db on which the AggSender will store the data
	StoragePath string `mapstructure:"StoragePath"`
	// AggLayerURL is the URL of the AggLayer
	AggLayerURL string `mapstructure:"AggLayerURL"`
	// BlockGetInterval is the interval at which the AggSender will get the blocks from L1
	BlockGetInterval types.Duration `mapstructure:"BlockGetInterval"`
	// CheckSettledInterval is the interval at which the AggSender will check if the blocks are settled
	CheckSettledInterval types.Duration `mapstructure:"CheckSettledInterval"`
	// AggsenderPrivateKey is the private key which is used to sign certificates
	AggsenderPrivateKey types.KeystoreFileConfig `mapstructure:"AggsenderPrivateKey"`
	// URLRPCL2 is the URL of the L2 RPC node
	URLRPCL2 string `mapstructure:"URLRPCL2"`
	// BlockFinality indicates which finality follows AggLayer
	BlockFinality string `` //nolint:lll
	/* 134-byte string literal not displayed */
	// EpochNotificationPercentage indicates the percentage of the epoch
	// the AggSender should send the certificate
	// 0 -> Begin
	// 50 -> Middle
	EpochNotificationPercentage uint `mapstructure:"EpochNotificationPercentage"`
	// SaveCertificatesToFilesPath if != "" tells  the AggSender to save the certificates to a file in this path
	SaveCertificatesToFilesPath string `mapstructure:"SaveCertificatesToFilesPath"`
}

Config is the configuration for the AggSender

func (Config) String

func (c Config) String() string

String returns a string representation of the Config

type ConfigBlockNotifierPolling

type ConfigBlockNotifierPolling struct {
	// BlockFinalityType is the finality of the block to be notified
	BlockFinalityType etherman.BlockNumberFinality
	// CheckNewBlockInterval is the interval at which the AggSender will check for new blocks
	// if is 0 it will be calculated automatically
	CheckNewBlockInterval time.Duration
}

type ConfigEpochNotifierPerBlock

type ConfigEpochNotifierPerBlock struct {
	StartingEpochBlock uint64
	NumBlockPerEpoch   uint

	// EpochNotificationPercentage
	// 0 -> begin new Epoch
	// 50 -> middle of epoch
	// 100 -> end of epoch (same as 0)
	EpochNotificationPercentage uint
}

func NewConfigEpochNotifierPerBlock

func NewConfigEpochNotifierPerBlock(aggLayer agglayer.AggLayerClientGetEpochConfiguration,
	epochNotificationPercentage uint) (*ConfigEpochNotifierPerBlock, error)

func (*ConfigEpochNotifierPerBlock) Validate

func (c *ConfigEpochNotifierPerBlock) Validate() error

type EpochNotifierPerBlock

type EpochNotifierPerBlock struct {
	Config ConfigEpochNotifierPerBlock
	types.GenericSubscriber[types.EpochEvent]
	// contains filtered or unexported fields
}

func NewEpochNotifierPerBlock

func NewEpochNotifierPerBlock(blockNotifier types.BlockNotifier,
	logger types.Logger,
	config ConfigEpochNotifierPerBlock,
	subscriber types.GenericSubscriber[types.EpochEvent]) (*EpochNotifierPerBlock, error)

func (*EpochNotifierPerBlock) Start

func (e *EpochNotifierPerBlock) Start(ctx context.Context)

Start starts the notifier synchronously

func (*EpochNotifierPerBlock) StartAsync

func (e *EpochNotifierPerBlock) StartAsync(ctx context.Context)

StartAsync starts the notifier in a goroutine

func (*EpochNotifierPerBlock) String

func (e *EpochNotifierPerBlock) String() string

type ExtraInfoEventEpoch

type ExtraInfoEventEpoch struct {
	PendingBlocks int
}

func (*ExtraInfoEventEpoch) String

func (e *ExtraInfoEventEpoch) String() string

type GenericSubscriberImpl

type GenericSubscriberImpl[T any] struct {
	// contains filtered or unexported fields
}

func NewGenericSubscriberImpl

func NewGenericSubscriberImpl[T any]() *GenericSubscriberImpl[T]

func (*GenericSubscriberImpl[T]) Publish

func (g *GenericSubscriberImpl[T]) Publish(data T)

func (*GenericSubscriberImpl[T]) Subscribe

func (g *GenericSubscriberImpl[T]) Subscribe(subscriberName string) <-chan T

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

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