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 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 ¶
UpdateCurrentFunc updates the iterator.current cursor in the iterator.
Click to show internal directories.
Click to hide internal directories.