fetch

package
v0.5.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultMaxSlots     = 100
	DefaultMaxChunkSize = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// GetLatestBlockNumber returns the latest block height from the chain
	GetLatestBlockNumber() (uint64, error)

	// GetBlock returns specified block
	GetBlock(uint64) (*core_types.ResultBlock, error)

	// GetGenesis returns the genesis block
	GetGenesis() (*core_types.ResultGenesis, error)

	// GetBlockResults returns the results of executing the transactions
	// for the specified block
	GetBlockResults(uint64) (*core_types.ResultBlockResults, error)

	// CreateBatch creates a new client batch
	CreateBatch() clientTypes.Batch
}

Client defines the interface for the node (client) communication

type Events

type Events interface {
	// SignalEvent signals a new event to the event manager
	SignalEvent(events.Event)
}

Events is the events API

type Fetcher

type Fetcher struct {
	// contains filtered or unexported fields
}

Fetcher is an instance of the block indexer fetcher

func New

func New(
	storage storage.Storage,
	client Client,
	events Events,
	opts ...Option,
) *Fetcher

New creates a new data fetcher instance that gets blockchain data from a remote chain

func (*Fetcher) FetchChainData

func (f *Fetcher) FetchChainData(ctx context.Context) error

FetchChainData starts the fetching process that indexes blockchain data

type Option

type Option func(f *Fetcher)

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger sets the logger to be used with the fetcher

func WithMaxChunkSize

func WithMaxChunkSize(maxChunkSize int64) Option

WithMaxChunkSize sets the maximum worker chunk size (data range) for the fetcher

func WithMaxSlots

func WithMaxSlots(maxSlots int) Option

WithMaxSlots sets the maximum worker slots for the fetcher

Jump to

Keyboard shortcuts

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