ariadne

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: Apache-2.0 Imports: 12 Imported by: 1

README

Ariadne

img img img

Ariadne is a library for fetching blocks from cosmos based blockchain node. The library is helpful at off-chain services building.

Install

go get -u github.com/Decentr-net/ariadne

Usage

Short example:

f, err := ariadne.New(nodeAddr, cdc, time.Minute)
if err != nil { panic(err) }

_ = f.FetchBlocks(context.Background(), 1, func (b Block) error {
    fmt.Sprintf("%+v\n", b)
    return nil
})

You have to look at detailed example here

Contributing

Feel free to create issues and send pull requests!

License

This project is under Apache-2.0 License

Documentation

Overview

Package ariadne 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    []sdk.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 added in v1.0.0

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)
}

Fetcher interface for fetching.

func New

func New(ctx context.Context, node string, timeout time.Duration) (Fetcher, error)

New returns new instance of fetcher.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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