Documentation ¶
Overview ¶
Package fetcher is a library for fetching blocks from cosmos based blockchain node.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrTooHighBlockRequested = errors.New("too high block requested")
ErrTooHighBlockRequested returned when blockchain's height is less than requested.
Functions ¶
This section is empty.
Types ¶
type Block ¶
Block presents transactions and height. If you need have more information open new issue on github or DIY and send pull request.
type FetchBlocksOption ¶
type FetchBlocksOption func(f *FetchBlocksOptions)
FetchBlocksOption is used to tune FetchBlocks method.
func WithErrHandler ¶
func WithErrHandler(f func(height uint64, err error)) FetchBlocksOption
WithErrHandler sets function to process errors.
func WithRetryInterval ¶
func WithRetryInterval(d time.Duration) FetchBlocksOption
WithRetryInterval sets pause duration after error.
func WithRetryLastBlockInterval ¶
func WithRetryLastBlockInterval(d time.Duration) FetchBlocksOption
WithRetryLastBlockInterval sets how long should fetcher wait if fetcher got ErrTooHighBlockRequested.
func WithSkipError ¶
func WithSkipError(b bool) FetchBlocksOption
WithSkipError disable retries of block handling with handleFunc.
type FetchBlocksOptions ¶
type FetchBlocksOptions struct {
// contains filtered or unexported fields
}
FetchBlocksOptions is config for FetchBlocks method.
type Fetcher ¶
type Fetcher interface { // FetchBlocks starts fetching routine and runs handleFunc for every block. FetchBlocks(ctx context.Context, from uint64, handleFunc func(b Block) error, opts ...FetchBlocksOption) error // FetchBlock fetches block from blockchain. // If height is zero then the highest block will be requested. FetchBlock(ctx context.Context, height uint64) (*Block, error) // PingContext checks if possible to get latest block. PingContext(ctx context.Context) error }
Fetcher interface for fetching.