blocksync

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, getBlocks BlocksLoaderFunc, startingBlockNumber, maxBlockNumber uint64, batchSize int, processor BlockProcessorFunc) error

Run loads blocks using "getBlocks" and processes them using "processor" until:

  • ctx is cancelled;
  • maxBlockNumber param is not zero and block with that number has been processed;
  • unrecoverable error is encountered.

Other parameters:

  • startingBlockNumber is the first block number to ask for (using getBlocks) must be > 0;
  • maxBlockNumber: when zero Run loads new blocks until ctx is cancelled, when not zero blocks are loaded until block with given number has been processed;
  • batchSize how big batches to use (used for getBlocks parameter);

Run returns non-nil error unless maxBlockNumber param is not zero and that block is loaded and processed successfully.

Types

type BlockProcessorFunc

type BlockProcessorFunc func(context.Context, *types.Block) error

type BlocksLoaderFunc

type BlocksLoaderFunc func(ctx context.Context, blockNumber, batchSize uint64) (*alphabill.GetBlocksResponse, error)

Jump to

Keyboard shortcuts

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