Documentation
¶
Index ¶
- Variables
- type Config
- type LimiterConfig
- type Manager
- func (s *Manager) CountIncompleteBlocks(ctx context.Context, network, processor string) (int, error)
- func (s *Manager) GetHeadDistance(ctx context.Context, processor, network, mode string, executionHead *big.Int) (distance int64, headType string, err error)
- func (s *Manager) GetIncompleteBlocks(ctx context.Context, network, processor string, limit int) ([]uint64, error)
- func (s *Manager) GetIncompleteBlocksInRange(ctx context.Context, network, processor string, minBlock, maxBlock uint64, ...) ([]uint64, error)
- func (s *Manager) GetMinMaxStoredBlocks(ctx context.Context, network, processor string) (minBlock, maxBlock *big.Int, err error)
- func (s *Manager) GetMissingBlocksInRange(ctx context.Context, network, processor string, minBlock, maxBlock uint64, ...) ([]uint64, error)
- func (s *Manager) GetNewestIncompleteBlock(ctx context.Context, network, processor string, maxBlockNumber uint64) (*uint64, error)
- func (s *Manager) GetOldestIncompleteBlock(ctx context.Context, network, processor string, minBlockNumber uint64) (*uint64, error)
- func (s *Manager) IsBlockComplete(ctx context.Context, blockNumber uint64, network, processor string) (bool, error)
- func (s *Manager) IsBlockRecentlyProcessed(ctx context.Context, blockNumber uint64, network, processor string, ...) (bool, error)
- func (s *Manager) MarkBlockComplete(ctx context.Context, blockNumber uint64, network, processor string) error
- func (s *Manager) MarkBlockEnqueued(ctx context.Context, blockNumber uint64, taskCount int, ...) error
- func (s *Manager) MarkBlockProcessed(ctx context.Context, blockNumber uint64, network, processor string) error
- func (s *Manager) NextBlock(ctx context.Context, processor, network, mode string, chainHead *big.Int) (*big.Int, error)
- func (s *Manager) NextBlocks(ctx context.Context, processor, network, mode string, chainHead *big.Int, ...) ([]*big.Int, error)
- func (s *Manager) SetNetwork(network string)
- func (s *Manager) Start(ctx context.Context) error
- func (s *Manager) Stop(ctx context.Context) error
- type StorageConfig
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoMoreBlocks = errors.New("no more blocks to process")
)
Sentinel errors.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Storage StorageConfig `yaml:"storage"`
Limiter LimiterConfig `yaml:"limiter"`
}
type LimiterConfig ¶
type LimiterConfig struct {
Enabled bool `yaml:"enabled"`
clickhouse.Config `yaml:",inline"`
Table string `yaml:"table"`
}
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(log logrus.FieldLogger, config *Config) (*Manager, error)
func (*Manager) CountIncompleteBlocks ¶ added in v0.1.5
func (s *Manager) CountIncompleteBlocks(ctx context.Context, network, processor string) (int, error)
CountIncompleteBlocks returns the count of blocks that are not yet complete.
func (*Manager) GetHeadDistance ¶ added in v0.0.8
func (s *Manager) GetHeadDistance(ctx context.Context, processor, network, mode string, executionHead *big.Int) (distance int64, headType string, err error)
GetHeadDistance calculates the distance between current processing block and the relevant head.
func (*Manager) GetIncompleteBlocks ¶ added in v0.1.5
func (s *Manager) GetIncompleteBlocks(ctx context.Context, network, processor string, limit int) ([]uint64, error)
GetIncompleteBlocks returns block numbers that are not yet complete, ordered by block_number.
func (*Manager) GetIncompleteBlocksInRange ¶ added in v0.1.5
func (s *Manager) GetIncompleteBlocksInRange( ctx context.Context, network, processor string, minBlock, maxBlock uint64, limit int, ) ([]uint64, error)
GetIncompleteBlocksInRange returns all incomplete blocks between minBlock and maxBlock. This is used for gap detection across the full processed range.
func (*Manager) GetMinMaxStoredBlocks ¶ added in v0.0.4
func (*Manager) GetMissingBlocksInRange ¶ added in v0.1.5
func (s *Manager) GetMissingBlocksInRange( ctx context.Context, network, processor string, minBlock, maxBlock uint64, limit int, ) ([]uint64, error)
GetMissingBlocksInRange returns block numbers that have no row in the database. This finds blocks that were never processed, not incomplete blocks. Uses ClickHouse's numbers() function to generate a sequence and NOT IN to find gaps.
func (*Manager) GetNewestIncompleteBlock ¶ added in v0.1.5
func (s *Manager) GetNewestIncompleteBlock(ctx context.Context, network, processor string, maxBlockNumber uint64) (*uint64, error)
GetNewestIncompleteBlock returns the newest incomplete block <= maxBlockNumber. Returns nil if no incomplete blocks exist within the range. The maxBlockNumber parameter enables startup optimization by limiting the search range. This method is used for backwards processing mode.
func (*Manager) GetOldestIncompleteBlock ¶ added in v0.1.5
func (s *Manager) GetOldestIncompleteBlock(ctx context.Context, network, processor string, minBlockNumber uint64) (*uint64, error)
GetOldestIncompleteBlock returns the oldest incomplete block >= minBlockNumber. Returns nil if no incomplete blocks exist within the range. The minBlockNumber parameter enables startup optimization by limiting the search range.
func (*Manager) IsBlockComplete ¶ added in v0.1.5
func (s *Manager) IsBlockComplete(ctx context.Context, blockNumber uint64, network, processor string) (bool, error)
IsBlockComplete checks if a block is marked complete in ClickHouse. Uses FINAL to get the latest state after ReplacingMergeTree deduplication. This is used to prevent race conditions where a block completes between gap detection scan and the reprocess decision.
func (*Manager) IsBlockRecentlyProcessed ¶ added in v0.0.8
func (s *Manager) IsBlockRecentlyProcessed(ctx context.Context, blockNumber uint64, network, processor string, withinSeconds int) (bool, error)
IsBlockRecentlyProcessed checks if a block was processed within the specified number of seconds.
func (*Manager) MarkBlockComplete ¶ added in v0.1.5
func (s *Manager) MarkBlockComplete(ctx context.Context, blockNumber uint64, network, processor string) error
MarkBlockComplete inserts a block with complete=true to indicate all tasks finished. This is the second phase of two-phase completion tracking. ReplacingMergeTree will keep the latest row per (processor, network, block_number).
func (*Manager) MarkBlockEnqueued ¶ added in v0.1.5
func (s *Manager) MarkBlockEnqueued(ctx context.Context, blockNumber uint64, taskCount int, network, processor string) error
MarkBlockEnqueued inserts a block with complete=false to track that tasks have been enqueued. This is the first phase of two-phase completion tracking.
func (*Manager) MarkBlockProcessed ¶
func (*Manager) NextBlocks ¶ added in v0.1.5
func (s *Manager) NextBlocks( ctx context.Context, processor, network, mode string, chainHead *big.Int, count int, ) ([]*big.Int, error)
NextBlocks returns up to `count` sequential block numbers starting from what NextBlock returns. This is used for batch block fetching to get multiple consecutive blocks at once.
func (*Manager) SetNetwork ¶ added in v0.0.5
SetNetwork sets the network name for metrics labeling.
type StorageConfig ¶
type StorageConfig struct {
clickhouse.Config `yaml:",inline"`
Table string `yaml:"table"`
}