backend

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 13 Imported by: 2

Documentation

Overview

Package backend handles the scribe backend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockHashesInRange

func BlockHashesInRange(ctx context.Context, backend ScribeBackend, startHeight uint64, endHeight uint64) (*immutable.Map[uint64, string], error)

BlockHashesInRange gets all block hashes in a range with a single batch request in successful cases an immutable map is returned of [height->hash], otherwise an error is returned.

func GetLogsInRange

func GetLogsInRange(ctx context.Context, backend ScribeBackend, contractAddresses []common.Address, expectedChainID uint64, chunks []*util.Chunk, topics [][]common.Hash) (*immutable.List[*[]types.Log], error)

GetLogsInRange gets all logs in a range with a single batch request in successful cases an immutable list is returned, otherwise an error is returned.

func MakeRange

func MakeRange[T constraints.Integer](min, max T) []T

MakeRange returns a range of integers from min to max inclusive.

Types

type ScribeBackend

type ScribeBackend interface {
	// ChainID gets the chain id from the rpc server.
	ChainID(ctx context.Context) (*big.Int, error)
	// BlockNumber gets the latest block number.
	BlockNumber(ctx context.Context) (uint64, error)
	// HeaderByNumber returns the block header with the given block number.
	HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
	// BatchWithContext batches multiple
	BatchWithContext(ctx context.Context, calls ...w3types.Caller) error
}

ScribeBackend is the set of functions that the scribe needs from a client.

func DialBackend

func DialBackend(ctx context.Context, url string, handler metrics.Handler) (ScribeBackend, error)

DialBackend returns a scribe backend.

Jump to

Keyboard shortcuts

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