chainiterator

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBlocksReadPerEpoch = 1000
	DefaultRetryInterval      = 12 * time.Second
	DefaultBlockConfirmations = 0
)

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                *rpc.EthClient
	MaxBlocksReadPerEpoch *uint64
	StartHeight           *big.Int
	EndHeight             *big.Int
	OnBlocks              OnBlocksFunc
	ReorgRewindDepth      *uint64
	RetryInterval         time.Duration
	BlockConfirmations    *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