fetcher

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package fetcher is a library for fetching blocks from cosmos based blockchain node.

Index

Constants

This section is empty.

Variables

View Source
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

type Block struct {
	Height uint64
	Time   time.Time
	Txs    []Tx
}

Block presents transactions and height. If you need have more information open new issue on github or DIY and send pull request.

func (Block) Messages

func (b Block) Messages() []sdk.Msg

Messages returns all messages in all transactions.

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.

func New

func New(conn *grpc.ClientConn, timeout time.Duration) Fetcher

New returns new instance of fetcher.

type Tx added in v0.0.2

type Tx struct {
	Messages []sdk.Msg
	Hash     string
	Memo     string
}

Jump to

Keyboard shortcuts

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