hypersyncgo

package module
v0.0.0-...-5068cfe Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MPL-2.0 Imports: 22 Imported by: 0

README

Tests Status Security Status Coverage Status

HyperSync Go Client

WIP - reach out in discord if you need this :)

Golang client for Envio's HyperSync, HyperRPC and HyperCURL clients.

Documentation Page
envio

Installation

go get github.com/enviodev/hypersync-client-go

Examples

See more at Examples directory.

LICENSE

copyright goes here...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do[R any, T any](ctx context.Context, c *Client, url string, method string, payload R) (*T, error)

func DoArrow

func DoArrow[R any](ctx context.Context, c *Client, url string, method string, payload R) (*types.QueryResponse, error)

func DoQuery

func DoQuery[R any, T any](ctx context.Context, c *Client, method string, payload R) (*T, error)

Types

type ArchiveHeight

type ArchiveHeight struct {
	Height *big.Int `json:"height"`
}

type Client

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

func NewClient

func NewClient(ctx context.Context, opts options.Node) (*Client, error)

func (*Client) BlockByNumber

func (c *Client) BlockByNumber(ctx context.Context, blockNumber *big.Int) (*types.Block, error)

func (*Client) GeUrlFromNodeAndPath

func (c *Client) GeUrlFromNodeAndPath(node options.Node, path ...string) string

func (*Client) Get

func (c *Client) Get(ctx context.Context, query *types.Query) (*types.QueryResponse, error)

func (*Client) GetArrow

func (c *Client) GetArrow(ctx context.Context, query *types.Query) (*types.QueryResponse, error)

func (*Client) GetContractCreator

func (c *Client) GetContractCreator(ctx context.Context, addr common.Address) (*ContractCreatorResponse, error)

GetContractCreator fetches the transaction details of the creator of a specified contract address.

This function sends a POST request to the Envio API to retrieve information about the contract creator. It takes the context, network ID, and contract address as parameters and returns the transaction details.

Parameters: - ctx: The context for managing the request lifecycle. - networkId: The ID of the network where the contract is deployed. - addr: The contract address for which the creator's transaction details are to be fetched.

Returns: - *Transaction: The transaction details of the contract creator, if found. - error: An error if the request fails or the contract is not found.

func (*Client) GetHeight

func (c *Client) GetHeight(ctx context.Context) (*big.Int, error)

func (*Client) GetQueryUrlFromNode

func (c *Client) GetQueryUrlFromNode(node options.Node) string

func (*Client) GetRPC

func (c *Client) GetRPC() *ethclient.Client

func (*Client) HeaderByNumber

func (c *Client) HeaderByNumber(ctx context.Context, blockNumber *big.Int) (*types.Header, error)

func (*Client) Stream

func (c *Client) Stream(ctx context.Context, query *types.Query, opts *options.StreamOptions) (*Stream, error)

func (*Client) StreamBlocksInRange

func (c *Client) StreamBlocksInRange(ctx context.Context, fromBlock *big.Int, toBlock *big.Int, opts *options.StreamOptions) (*Stream, error)

func (*Client) StreamFullBlocksInRange

func (c *Client) StreamFullBlocksInRange(ctx context.Context, fromBlock *big.Int, toBlock *big.Int, opts *options.StreamOptions) (*Stream, error)

func (*Client) StreamLogsInRange

func (c *Client) StreamLogsInRange(ctx context.Context, fromBlock *big.Int, toBlock *big.Int, selections []types.LogSelection, opts *options.StreamOptions) (*Stream, error)

func (*Client) StreamTracesInRange

func (c *Client) StreamTracesInRange(ctx context.Context, fromBlock *big.Int, toBlock *big.Int, selections []types.TraceSelection, opts *options.StreamOptions) (*Stream, error)

func (*Client) StreamTransactionsInRange

func (c *Client) StreamTransactionsInRange(ctx context.Context, fromBlock *big.Int, toBlock *big.Int, selections []types.TransactionSelection, opts *options.StreamOptions) (*Stream, error)

type ContractCreatorResponse

type ContractCreatorResponse struct {
	Number *big.Int       `json:"number"`
	Hash   common.Hash    `json:"hash"`
	From   common.Address `json:"from"`
}

type Hyper

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

Hyper manages a collection of blockchain clients.

func NewHyper

func NewHyper(ctx context.Context, opts options.Options) (*Hyper, error)

NewHyper creates a new instance of HyperSync with the given context and options. It validates the provided options and initializes clients for each blockchain network.

Returns an error if the options are invalid or if a client for any network cannot be created.

func (*Hyper) GetClient

func (h *Hyper) GetClient(networkId utils.NetworkID) (*Client, bool)

GetClient returns a specific blockchain client by its network ID. The boolean return value indicates whether the client was found.

func (*Hyper) GetClients

func (h *Hyper) GetClients() map[utils.NetworkID]*Client

GetClients returns a map of all blockchain clients managed by HyperSync.

type Stream

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

Stream represents a streaming process that handles data queries and responses using a client and worker for concurrent processing.

func NewStream

func NewStream(ctx context.Context, client *Client, query *types.Query, opts *options.StreamOptions) (*Stream, error)

NewStream creates a new Stream instance with the provided context, client, query, and options.

func (*Stream) Ack

func (s *Stream) Ack()

Ack acknowledges that a response has been processed. This method is thread-safe.

func (*Stream) Channel

func (s *Stream) Channel() <-chan *types.QueryResponse

Channel returns the stream's response channel.

func (*Stream) Done

func (s *Stream) Done() <-chan struct{}

Done returns a channel that signals when the stream is done.

func (*Stream) Err

func (s *Stream) Err() <-chan error

Err returns the stream's error channel.

func (*Stream) ProcessNextQuery

func (s *Stream) ProcessNextQuery(query *types.Query) (*types.QueryResponse, error)

ProcessNextQuery processes the next query using the client and returns the response or error.

func (*Stream) QueueError

func (s *Stream) QueueError(err error)

QueueError adds an error to the stream's error channel.

func (*Stream) Subscribe

func (s *Stream) Subscribe() error

Subscribe starts the streaming process, initializing the first query and handling subsequent ones.

func (*Stream) Unsubscribe

func (s *Stream) Unsubscribe() error

Unsubscribe stops the stream and closes all channels associated with it.

Directories

Path Synopsis
Package arrowhs provides functionality to read and process query responses using Cap'n Proto for message decoding and Apache Arrow for data processing.
Package arrowhs provides functionality to read and process query responses using Cap'n Proto for message decoding and Apache Arrow for data processing.
Package logger provides a global logging interface for structured logging.
Package logger provides a global logging interface for structured logging.
Package streams provides a framework for creating and managing concurrent worker pools to process streams of data, including utilities for iterating over blocks of data.
Package streams provides a framework for creating and managing concurrent worker pools to process streams of data, including utilities for iterating over blocks of data.
Package types provides the definitions for various data structures used in the hypersync-client-go library.
Package types provides the definitions for various data structures used in the hypersync-client-go library.

Jump to

Keyboard shortcuts

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