chainiterator

package
v0.0.0-...-1d04f91 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBlocksReadPerEpoch = 1000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockBatchIterator

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

BlockBatchIterator iterates the blocks in batches between the given start and end heights, with the awareness of reorganization.

func NewBlockBatchIterator

func NewBlockBatchIterator(ctx context.Context, cfg *BlockBatchIteratorConfig) (*BlockBatchIterator, error)

NewBlockBatchIterator creates a new block batch iterator instance.

func (*BlockBatchIterator) Iter

func (i *BlockBatchIterator) Iter() error

Iter iterates the given chain between the given start and end heights, will call the callback when a batch of blocks in chain are iterated.

type BlockBatchIteratorConfig

type BlockBatchIteratorConfig struct {
	Client                *ethclient.Client
	MaxBlocksReadPerEpoch *uint64
	StartHeight           *big.Int
	EndHeight             *big.Int
	OnBlocks              OnBlocksFunc
	Reverse               bool
	ReorgRewindDepth      *uint64
}

BlockBatchIteratorConfig represents the configs of a block batch iterator.

type EndIterFunc

type EndIterFunc func()

EndIterFunc ends the current iteration.

type OnBlocksFunc

type OnBlocksFunc func(
	ctx context.Context,
	start, end *types.Header,
	updateCurrentFunc UpdateCurrentFunc,
	endIterFunc EndIterFunc,
) error

OnBlocksFunc represents the callback function which will be called when a batch of blocks in chain are iterated. It returns true if it reorged, and false if not.

type UpdateCurrentFunc

type UpdateCurrentFunc func(*types.Header)

UpdateCurrentFunc updates the iterator.current cursor in the iterator.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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