Documentation ¶
Index ¶
- Constants
- Variables
- func NewNetworkAPI(state protocol.State, chainID flow.ChainID, snapshotHistoryLimit int) *backendNetwork
- func WithClientUnaryInterceptor(timeout time.Duration) grpc.DialOption
- type Backend
- func (b *Backend) ExecuteScriptAtBlockHeight(ctx context.Context, blockHeight uint64, script []byte, arguments [][]byte) ([]byte, error)
- func (b *Backend) ExecuteScriptAtBlockID(ctx context.Context, blockID flow.Identifier, script []byte, ...) ([]byte, error)
- func (b *Backend) ExecuteScriptAtLatestBlock(ctx context.Context, script []byte, arguments [][]byte) ([]byte, error)
- func (b *Backend) GetAccount(ctx context.Context, address flow.Address) (*flow.Account, error)
- func (b *Backend) GetAccountAtBlockHeight(ctx context.Context, address flow.Address, height uint64) (*flow.Account, error)
- func (b *Backend) GetAccountAtLatestBlock(ctx context.Context, address flow.Address) (*flow.Account, error)
- func (b *Backend) GetBlockByHeight(_ context.Context, height uint64) (*flow.Block, flow.BlockStatus, error)
- func (b *Backend) GetBlockByID(_ context.Context, id flow.Identifier) (*flow.Block, flow.BlockStatus, error)
- func (b *Backend) GetBlockHeaderByHeight(_ context.Context, height uint64) (*flow.Header, flow.BlockStatus, error)
- func (b *Backend) GetBlockHeaderByID(_ context.Context, id flow.Identifier) (*flow.Header, flow.BlockStatus, error)
- func (b *Backend) GetCollectionByID(_ context.Context, colID flow.Identifier) (*flow.LightCollection, error)
- func (b *Backend) GetEventsForBlockIDs(ctx context.Context, eventType string, blockIDs []flow.Identifier) ([]flow.BlockEvents, error)
- func (b *Backend) GetEventsForHeightRange(ctx context.Context, eventType string, startHeight, endHeight uint64) ([]flow.BlockEvents, error)
- func (b *Backend) GetExecutionResultByID(ctx context.Context, id flow.Identifier) (*flow.ExecutionResult, error)
- func (b *Backend) GetExecutionResultForBlockID(ctx context.Context, blockID flow.Identifier) (*flow.ExecutionResult, error)
- func (b *Backend) GetLatestBlock(_ context.Context, isSealed bool) (*flow.Block, flow.BlockStatus, error)
- func (b *Backend) GetLatestBlockHeader(_ context.Context, isSealed bool) (*flow.Header, flow.BlockStatus, error)
- func (b *Backend) GetLatestProtocolStateSnapshot(_ context.Context) ([]byte, error)
- func (b *Backend) GetNetworkParameters(_ context.Context) access.NetworkParameters
- func (b *Backend) GetTransaction(ctx context.Context, txID flow.Identifier) (*flow.TransactionBody, error)
- func (b *Backend) GetTransactionResult(ctx context.Context, txID flow.Identifier) (*access.TransactionResult, error)
- func (b *Backend) GetTransactionResultByIndex(ctx context.Context, blockID flow.Identifier, index uint32) (*access.TransactionResult, error)
- func (b *Backend) GetTransactionResultsByBlockID(ctx context.Context, blockID flow.Identifier) ([]*access.TransactionResult, error)
- func (b *Backend) GetTransactionsByBlockID(ctx context.Context, blockID flow.Identifier) ([]*flow.TransactionBody, error)
- func (b *Backend) NotifyFinalizedBlockHeight(height uint64)
- func (b *Backend) Ping(ctx context.Context) error
- func (b *Backend) SendRawTransaction(ctx context.Context, tx *flow.TransactionBody) error
- func (b *Backend) SendTransaction(ctx context.Context, tx *flow.TransactionBody) error
- type CachedClient
- type ConnectionFactory
- type ConnectionFactoryImpl
- func (cf *ConnectionFactoryImpl) GetAccessAPIClient(address string) (access.AccessAPIClient, io.Closer, error)
- func (cf *ConnectionFactoryImpl) GetExecutionAPIClient(address string) (execution.ExecutionAPIClient, io.Closer, error)
- func (cf *ConnectionFactoryImpl) InvalidateAccessAPIClient(address string)
- func (cf *ConnectionFactoryImpl) InvalidateExecutionAPIClient(address string)
- type InsufficientExecutionReceipts
- type ProxyConnectionFactory
- type Retry
Constants ¶
const DefaultClientTimeout = 3 * time.Second
DefaultClientTimeout is used when making a GRPC request to a collection node or an execution node
const DefaultConnectionPoolSize = 250
DefaultConnectionPoolSize is the default size for the connection pool to collection and execution nodes
const DefaultLoggedScriptsCacheSize = 1_000_000
DefaultLoggedScriptsCacheSize is the default size of the lookup cache used to dedupe logs of scripts sent to ENs limiting cache size to 16MB and does not affect script execution, only for keeping logs tidy
const DefaultMaxHeightRange = 250
DefaultMaxHeightRange is the default maximum size of range requests.
const DefaultSnapshotHistoryLimit = 50
DefaultSnapshotHistoryLimit the amount of blocks to look back in state when recursively searching for a valid snapshot
Variables ¶
var SnapshotHistoryLimitErr = fmt.Errorf("reached the snapshot history limit")
Functions ¶
func NewNetworkAPI ¶ added in v0.28.0
func NewNetworkAPI(state protocol.State, chainID flow.ChainID, snapshotHistoryLimit int) *backendNetwork
NetworkAPI func
The observer and access nodes need to be able to handle GetNetworkParameters and GetLatestProtocolStateSnapshot RPCs so this logic was split into the backendNetwork so that we can ignore the rest of the backend logic
func WithClientUnaryInterceptor ¶ added in v0.14.6
func WithClientUnaryInterceptor(timeout time.Duration) grpc.DialOption
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend implements the Access API.
It is composed of several sub-backends that implement part of the Access API.
Script related calls are handled by backendScripts. Transaction related calls are handled by backendTransactions. Block Header related calls are handled by backendBlockHeaders. Block details related calls are handled by backendBlockDetails. Event related calls are handled by backendEvents. Account related calls are handled by backendAccounts.
All remaining calls are handled by the base Backend in this file.
func New ¶
func New( state protocol.State, collectionRPC accessproto.AccessAPIClient, historicalAccessNodes []accessproto.AccessAPIClient, blocks storage.Blocks, headers storage.Headers, collections storage.Collections, transactions storage.Transactions, executionReceipts storage.ExecutionReceipts, executionResults storage.ExecutionResults, chainID flow.ChainID, transactionMetrics module.TransactionMetrics, connFactory ConnectionFactory, retryEnabled bool, maxHeightRange uint, preferredExecutionNodeIDs []string, fixedExecutionNodeIDs []string, log zerolog.Logger, snapshotHistoryLimit int, ) *Backend
func (*Backend) ExecuteScriptAtBlockHeight ¶
func (*Backend) ExecuteScriptAtBlockID ¶
func (*Backend) ExecuteScriptAtLatestBlock ¶
func (*Backend) GetAccount ¶
func (*Backend) GetAccountAtBlockHeight ¶
func (*Backend) GetAccountAtLatestBlock ¶
func (*Backend) GetBlockByHeight ¶
func (*Backend) GetBlockByID ¶
func (b *Backend) GetBlockByID(_ context.Context, id flow.Identifier) (*flow.Block, flow.BlockStatus, error)
func (*Backend) GetBlockHeaderByHeight ¶
func (*Backend) GetBlockHeaderByID ¶
func (b *Backend) GetBlockHeaderByID(_ context.Context, id flow.Identifier) (*flow.Header, flow.BlockStatus, error)
func (*Backend) GetCollectionByID ¶
func (b *Backend) GetCollectionByID(_ context.Context, colID flow.Identifier) (*flow.LightCollection, error)
func (*Backend) GetEventsForBlockIDs ¶
func (b *Backend) GetEventsForBlockIDs( ctx context.Context, eventType string, blockIDs []flow.Identifier, ) ([]flow.BlockEvents, error)
GetEventsForBlockIDs retrieves events for all the specified block IDs that have the given type
func (*Backend) GetEventsForHeightRange ¶
func (b *Backend) GetEventsForHeightRange( ctx context.Context, eventType string, startHeight, endHeight uint64, ) ([]flow.BlockEvents, error)
GetEventsForHeightRange retrieves events for all sealed blocks between the start block height and the end block height (inclusive) that have the given type.
func (*Backend) GetExecutionResultByID ¶ added in v0.23.5
func (b *Backend) GetExecutionResultByID(ctx context.Context, id flow.Identifier) (*flow.ExecutionResult, error)
GetExecutionResultByID gets an execution result by its ID.
func (*Backend) GetExecutionResultForBlockID ¶ added in v0.21.0
func (b *Backend) GetExecutionResultForBlockID(ctx context.Context, blockID flow.Identifier) (*flow.ExecutionResult, error)
func (*Backend) GetLatestBlock ¶
func (*Backend) GetLatestBlockHeader ¶
func (*Backend) GetLatestProtocolStateSnapshot ¶ added in v0.15.0
GetLatestProtocolStateSnapshot returns the latest finalized snapshot
func (*Backend) GetNetworkParameters ¶
func (b *Backend) GetNetworkParameters(_ context.Context) access.NetworkParameters
func (*Backend) GetTransaction ¶
func (b *Backend) GetTransaction(ctx context.Context, txID flow.Identifier) (*flow.TransactionBody, error)
func (*Backend) GetTransactionResult ¶
func (b *Backend) GetTransactionResult( ctx context.Context, txID flow.Identifier, ) (*access.TransactionResult, error)
func (*Backend) GetTransactionResultByIndex ¶ added in v0.24.8
func (b *Backend) GetTransactionResultByIndex( ctx context.Context, blockID flow.Identifier, index uint32, ) (*access.TransactionResult, error)
GetTransactionResultByIndex returns TransactionsResults for an index in a block that is executed, pending or finalized transactions return errors
func (*Backend) GetTransactionResultsByBlockID ¶ added in v0.24.11
func (b *Backend) GetTransactionResultsByBlockID( ctx context.Context, blockID flow.Identifier, ) ([]*access.TransactionResult, error)
func (*Backend) GetTransactionsByBlockID ¶ added in v0.24.11
func (b *Backend) GetTransactionsByBlockID( ctx context.Context, blockID flow.Identifier, ) ([]*flow.TransactionBody, error)
func (*Backend) NotifyFinalizedBlockHeight ¶
func (b *Backend) NotifyFinalizedBlockHeight(height uint64)
func (*Backend) SendRawTransaction ¶
func (b *Backend) SendRawTransaction( ctx context.Context, tx *flow.TransactionBody, ) error
SendRawTransaction sends a raw transaction to the collection node
func (*Backend) SendTransaction ¶
func (b *Backend) SendTransaction( ctx context.Context, tx *flow.TransactionBody, ) error
SendTransaction forwards the transaction to the collection node
type CachedClient ¶ added in v0.26.17
type CachedClient struct { ClientConn *grpc.ClientConn Address string // contains filtered or unexported fields }
func (*CachedClient) Close ¶ added in v0.26.17
func (s *CachedClient) Close()
type ConnectionFactory ¶
type ConnectionFactory interface { GetAccessAPIClient(address string) (access.AccessAPIClient, io.Closer, error) InvalidateAccessAPIClient(address string) GetExecutionAPIClient(address string) (execution.ExecutionAPIClient, io.Closer, error) InvalidateExecutionAPIClient(address string) }
ConnectionFactory is used to create an access api client
type ConnectionFactoryImpl ¶
type ConnectionFactoryImpl struct { CollectionGRPCPort uint ExecutionGRPCPort uint CollectionNodeGRPCTimeout time.Duration ExecutionNodeGRPCTimeout time.Duration ConnectionsCache *lru.Cache CacheSize uint AccessMetrics module.AccessMetrics Log zerolog.Logger // contains filtered or unexported fields }
func (*ConnectionFactoryImpl) GetAccessAPIClient ¶
func (cf *ConnectionFactoryImpl) GetAccessAPIClient(address string) (access.AccessAPIClient, io.Closer, error)
func (*ConnectionFactoryImpl) GetExecutionAPIClient ¶ added in v0.14.0
func (cf *ConnectionFactoryImpl) GetExecutionAPIClient(address string) (execution.ExecutionAPIClient, io.Closer, error)
func (*ConnectionFactoryImpl) InvalidateAccessAPIClient ¶ added in v0.26.16
func (cf *ConnectionFactoryImpl) InvalidateAccessAPIClient(address string)
func (*ConnectionFactoryImpl) InvalidateExecutionAPIClient ¶ added in v0.26.16
func (cf *ConnectionFactoryImpl) InvalidateExecutionAPIClient(address string)
type InsufficientExecutionReceipts ¶ added in v0.17.0
type InsufficientExecutionReceipts struct {
// contains filtered or unexported fields
}
InsufficientExecutionReceipts indicates that no execution receipt were found for a given block ID
func (InsufficientExecutionReceipts) Error ¶ added in v0.17.0
func (e InsufficientExecutionReceipts) Error() string
type ProxyConnectionFactory ¶ added in v0.21.0
type ProxyConnectionFactory struct { ConnectionFactory // contains filtered or unexported fields }
func (*ProxyConnectionFactory) GetAccessAPIClient ¶ added in v0.21.0
func (p *ProxyConnectionFactory) GetAccessAPIClient(address string) (access.AccessAPIClient, io.Closer, error)
func (*ProxyConnectionFactory) GetExecutionAPIClient ¶ added in v0.21.0
func (p *ProxyConnectionFactory) GetExecutionAPIClient(address string) (execution.ExecutionAPIClient, io.Closer, error)
type Retry ¶
type Retry struct {
// contains filtered or unexported fields
}
Retry implements a simple retry mechanism for transaction submission.
func (*Retry) RegisterTransaction ¶
func (r *Retry) RegisterTransaction(height uint64, tx *flow.TransactionBody)
RegisterTransaction adds a transaction that could possibly be retried