types

package
v0.10.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DownloadResult

type DownloadResult struct {
	Data sync.EVMBlocks
	// CompletionPercentage indicates the percent of completion of the download
	// 0 -> 0%, 100 -> 100%
	CompletionPercentage float64
}

type DownloaderInterface

type DownloaderInterface interface {
	// DownloadNextBlocks downloads the next blocks starting from fromBlockHeader
	// up to maxBlocks, according to the syncerConfig
	// parameters:
	// - fromBlockHeader: the block header to start downloading from (exclusive)
	//       If it's nil means that there are no previous blocks processed
	// - maxBlocks: the maximum number of blocks to return (it could return less or none)
	// - syncerConfig: the syncer configuration
	// returns:
	// - DownloadResult: the result of the download, containing the blocks and the percent complete
	//     DownloadResult is never nil
	//     DownloadResult.Data could be nil if no blocks were downloaded
	//     DownloadResult.CompletionPercentage indicates the percent of completion of the download
	//       0 -> 0%, 100 -> 100%
	// - error: if any error occurred during the download
	//   special error: errors.Is(err, ErrLogsNotAvailable) indicates that it works
	//    but there are no logs yet
	DownloadNextBlocks(ctx context.Context,
		fromBlockHeader *aggkittypes.BlockHeader,
		maxBlocks uint64,
		syncerConfig aggkittypes.SyncerConfig) (*DownloadResult, error)
	ChainID(ctx context.Context) (uint64, error)
}

type MultidownloaderInterface

type MultidownloaderInterface interface {
	// CheckValidBlock checks if the given blockNumber and blockHash are still valid
	// returns: isValid bool, reorgID uint64, err error
	CheckValidBlock(ctx context.Context, blockNumber uint64,
		blockHash common.Hash) (bool, uint64, error)
	// GetReorgedDataByReorgID retrieves the reorged data by reorg ID
	GetReorgedDataByReorgID(ctx context.Context, reorgID uint64) (*mdrtypes.ReorgData, error)
	// IsAvailable checks if the logs for the given query are available
	IsAvailable(query mdrtypes.LogQuery) bool
	// IsPartiallyAvailable checks if the logs for the given query are partially available
	IsPartiallyAvailable(query mdrtypes.LogQuery) (bool, *mdrtypes.LogQuery)
	// GetEthLogs retrieves the logs for the given query
	LogQuery(ctx context.Context, query mdrtypes.LogQuery) (mdrtypes.LogQueryResponse, error)
	// Finality is which block to consider final (typically finalizedBlock)
	Finality() aggkittypes.BlockNumberFinality
	// HeaderByNumber gets the block header for the given block number finality
	HeaderByNumber(ctx context.Context,
		number *aggkittypes.BlockNumberFinality) (*aggkittypes.BlockHeader, error)
	StorageHeaderByNumber(ctx context.Context,
		number *aggkittypes.BlockNumberFinality) (*aggkittypes.BlockHeader, mdrtypes.FinalizedType, error)
	// ChainID returns the chain ID of the EVM chain
	ChainID(ctx context.Context) (uint64, error)
}

type ProcessorInterface

type ProcessorInterface interface {
	// GetLastProcessedBlockHeader it must return the last processed block header.
	// or nil if no block has been processed yet.
	// It is used to determine from which block number the downloader should start.
	GetLastProcessedBlockHeader(ctx context.Context) (*aggkittypes.BlockHeader, error)
	// ProcessBlocks processes the block. It is called for all blocks that are downloaded and
	// must be processed.
	// NOTE: legacy syncer use ProcessBlock for each block but it's slower because
	// can't take advantage of batch processing. ProcessBlocks is called with batches of blocks
	// and it is more efficient.
	//  It is the responsibility of the syncer to process them in batch or one by one.
	ProcessBlocks(ctx context.Context, blocks *DownloadResult) error
	// Reorg is called when a reorg is detected. Must execute a syncer reorg if apply
	// it's possible that the reorged blocks doesn't affect to this syncer
	Reorg(ctx context.Context, firstReorgedBlock uint64) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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