access

package
v0.4.36 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package access provides a client interface for the Flow Access API.

Index

Constants

This section is empty.

Variables

View Source
var (
	// NoopMemoryGauge provides a no-op implementation of Cadence's
	// common.MemoryGauge.
	NoopMemoryGauge = MemoryGauge{}
)

Functions

func InterceptRateLimitUnary

func InterceptRateLimitUnary(ctx context.Context, method string, req, res interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

InterceptRateLimitUnary handles any rate limit headers set by Access API proxy servers.

func IsRateLimited

func IsRateLimited(err error) bool

IsRateLimited should return true if an upstream Access API server or Envoy has returned an error indicating that a request has been rate-limited.

NOTE(tav): This function needs to be kept in sync with the error message used in the InterceptRateLimitUnary function above and the one within the Flow Access API server's rate limit implementation.

Types

type Client

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

Client for the Flow Access API.

All methods except SendTransaction impose a default timeout of one minute.

func (Client) Account

func (c Client) Account(ctx context.Context, addr []byte) (*entities.Account, error)

Account returns the account for the given address from the latest sealed execution state.

func (Client) AccountAtHeight

func (c Client) AccountAtHeight(ctx context.Context, addr []byte, height uint64) (*entities.Account, error)

AccountAtHeight returns the account for the given address at the given block height.

func (Client) BlockByHeight

func (c Client) BlockByHeight(ctx context.Context, height uint64) (*entities.Block, error)

BlockByHeight returns the block for the given height.

func (Client) BlockByID

func (c Client) BlockByID(ctx context.Context, blockID []byte) (*entities.Block, error)

BlockByID returns the block for the given block ID.

func (Client) BlockEvents

func (c Client) BlockEvents(ctx context.Context, blockID []byte, typ string) ([]*entities.Event, error)

BlockEvents returns the events for the given block ID and event type.

func (Client) BlockHeaderByHeight

func (c Client) BlockHeaderByHeight(ctx context.Context, height uint64) (*entities.BlockHeader, error)

BlockHeaderByHeight returns the block header for the given height.

func (Client) BlockHeaderByID

func (c Client) BlockHeaderByID(ctx context.Context, blockID []byte) (*entities.BlockHeader, error)

BlockHeaderByID returns the block header for the given block ID.

func (Client) CollectionByID

func (c Client) CollectionByID(ctx context.Context, id []byte) (*entities.Collection, error)

CollectionByID returns the collection of transactions for the given collection ID.

func (Client) Execute

func (c Client) Execute(ctx context.Context, blockID []byte, script []byte, args []cadence.Value) (cadence.Value, error)

Execute returns the given Cadence script at the specified block ID.

func (Client) ExecutionResultForBlockID

func (c Client) ExecutionResultForBlockID(ctx context.Context, blockID []byte) (*entities.ExecutionResult, error)

ExecutionResultForBlockID returns the execution result for the given block ID.

func (Client) LatestBlockHeader

func (c Client) LatestBlockHeader(ctx context.Context) (*entities.BlockHeader, error)

LatestBlockHeader returns the block header for the most recently sealed block.

func (Client) LatestFinalizedBlockHeader added in v0.4.18

func (c Client) LatestFinalizedBlockHeader(ctx context.Context) (*entities.BlockHeader, error)

LatestFinalizedBlockHeader returns the block header for the most recently finalized block, i.e. one which hasn't been sealed yet.

func (Client) Ping

func (c Client) Ping(ctx context.Context) error

Ping returns whether the client was able to ping the Access API server.

func (*Client) SendTransaction

func (c *Client) SendTransaction(ctx context.Context, txn *entities.Transaction) ([]byte, error)

SendTransaction submits a transaction to the Flow network, and returns the transaction hash.

func (Client) ServerAddress

func (c Client) ServerAddress() string

ServerAddress returns the host:port of the Access API server.

func (Client) Transaction

func (c Client) Transaction(ctx context.Context, hash []byte) (*entities.Transaction, error)

Transaction returns the transaction info for the given transaction hash.

func (Client) TransactionResult

func (c Client) TransactionResult(ctx context.Context, blockID []byte, txnIndex uint32) (*access.TransactionResultResponse, error)

TransactionResult returns the transaction result for the given transaction index within the specified block.

func (Client) TransactionResultByHash added in v0.4.23

func (c Client) TransactionResultByHash(ctx context.Context, hash []byte) (*access.TransactionResultResponse, error)

TransactionResultByHash returns the transaction result for the given transaction hash. In case of duplicates for the same transaction hash, the returned result will only be for one of the submissions.

func (Client) TransactionResultsByBlockID

func (c Client) TransactionResultsByBlockID(ctx context.Context, blockID []byte) ([]*access.TransactionResultResponse, error)

TransactionResultsByBlockID returns the transaction results for the given block ID.

func (Client) TransactionsByBlockID

func (c Client) TransactionsByBlockID(ctx context.Context, blockID []byte) ([]*entities.Transaction, error)

TransactionsByBlockID returns the transactions for the given block ID.

type MemoryGauge added in v0.4.18

type MemoryGauge struct {
}

MemoryGauge implements a no-op memory gauge to support Cadence JSON decoding.

func (MemoryGauge) MeterMemory added in v0.4.18

func (m MemoryGauge) MeterMemory(usage common.MemoryUsage) error

MeterMemory implements the common.MemoryGauge interface.

type NodeConfig

type NodeConfig struct {
	// Address specifies the host:port for the gRPC endpoint.
	Address string `json:"address"`
	// PublicKey indicates that it should use TLS using libp2p certs derived
	// from the given public key.
	PublicKey string `json:"public_key"`
	// TLS indicates that it should use TLS using the system root CAs.
	TLS bool `json:"tls"`
}

NodeConfig defines the metadata needed to securely connect to an Access API server.

type Pool

type Pool []Client

Pool represents a pool of Flow Access API clients.

func New

func New(ctx context.Context, nodes []NodeConfig, store *cache.Store) Pool

New returns a Flow Access API client pool that will return random clients connected to one of the specified nodes.

func (Pool) Client

func (p Pool) Client() Client

Client returns a random client from the pool.

Jump to

Keyboard shortcuts

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