sync

package
v0.3.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Num    uint64
	Events []interface{}
}

type EVMBlock

type EVMBlock struct {
	EVMBlockHeader
	Events []interface{}
}

type EVMBlockHeader

type EVMBlockHeader struct {
	Num        uint64
	Hash       common.Hash
	ParentHash common.Hash
	Timestamp  uint64
}

type EVMDownloader

type EVMDownloader struct {
	EVMDownloaderInterface
	// contains filtered or unexported fields
}

func NewEVMDownloader

func NewEVMDownloader(
	syncerID string,
	ethClient EthClienter,
	syncBlockChunkSize uint64,
	blockFinalityType etherman.BlockNumberFinality,
	waitForNewBlocksPeriod time.Duration,
	appender LogAppenderMap,
	adressessToQuery []common.Address,
	rh *RetryHandler,
) (*EVMDownloader, error)

func (*EVMDownloader) Download

func (d *EVMDownloader) Download(ctx context.Context, fromBlock uint64, downloadedCh chan EVMBlock)

type EVMDownloaderImplementation

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

func NewEVMDownloaderImplementation

func NewEVMDownloaderImplementation(
	syncerID string,
	ethClient EthClienter,
	blockFinality *big.Int,
	waitForNewBlocksPeriod time.Duration,
	appender LogAppenderMap,
	topicsToQuery []common.Hash,
	adressessToQuery []common.Address,
	rh *RetryHandler,
) *EVMDownloaderImplementation

func (*EVMDownloaderImplementation) GetBlockHeader

func (d *EVMDownloaderImplementation) GetBlockHeader(ctx context.Context, blockNum uint64) (EVMBlockHeader, bool)

func (*EVMDownloaderImplementation) GetEventsByBlockRange

func (d *EVMDownloaderImplementation) GetEventsByBlockRange(ctx context.Context, fromBlock, toBlock uint64) []EVMBlock

func (*EVMDownloaderImplementation) GetLogs

func (d *EVMDownloaderImplementation) GetLogs(ctx context.Context, fromBlock, toBlock uint64) []types.Log

func (*EVMDownloaderImplementation) WaitForNewBlocks

func (d *EVMDownloaderImplementation) WaitForNewBlocks(
	ctx context.Context, lastBlockSeen uint64,
) (newLastBlock uint64)

type EVMDownloaderInterface

type EVMDownloaderInterface interface {
	WaitForNewBlocks(ctx context.Context, lastBlockSeen uint64) (newLastBlock uint64)
	GetEventsByBlockRange(ctx context.Context, fromBlock, toBlock uint64) []EVMBlock
	GetLogs(ctx context.Context, fromBlock, toBlock uint64) []types.Log
	GetBlockHeader(ctx context.Context, blockNum uint64) (EVMBlockHeader, bool)
}

type EVMDriver

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

func NewEVMDriver

func NewEVMDriver(
	reorgDetector ReorgDetector,
	processor processorInterface,
	downloader downloader,
	reorgDetectorID string,
	downloadBufferSize int,
	rh *RetryHandler,
) (*EVMDriver, error)

func (*EVMDriver) Sync

func (d *EVMDriver) Sync(ctx context.Context)

type EthClienter

type EthClienter interface {
	ethereum.LogFilterer
	ethereum.BlockNumberReader
	ethereum.ChainReader
	bind.ContractBackend
}

type LogAppenderMap

type LogAppenderMap map[common.Hash]func(b *EVMBlock, l types.Log) error

type ProcessorInterface

type ProcessorInterface interface {
	GetLastProcessedBlock(ctx context.Context) (uint64, error)
	ProcessBlock(block Block) error
	Reorg(firstReorgedBlock uint64) error
}

type ReorgDetector

type ReorgDetector interface {
	Subscribe(id string) (*reorgdetector.Subscription, error)
	AddBlockToTrack(ctx context.Context, id string, blockNum uint64, blockHash common.Hash) error
}

type RetryHandler

type RetryHandler struct {
	RetryAfterErrorPeriod      time.Duration
	MaxRetryAttemptsAfterError int
}

func (*RetryHandler) Handle

func (h *RetryHandler) Handle(funcName string, attempts int)

Jump to

Keyboard shortcuts

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