backend

package
v0.26.17-access-fix-dy... Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: AGPL-3.0 Imports: 29 Imported by: 4

Documentation

Index

Constants

View Source
const DefaultClientTimeout = 3 * time.Second

DefaultClientTimeout is used when making a GRPC request to a collection node or an execution node

View Source
const DefaultConnectionPoolSize = 50

DefaultConnectionPoolSize is the default size for the connection pool to collection and execution nodes

View Source
const DefaultMaxHeightRange = 250

DefaultMaxHeightRange is the default maximum size of range requests.

View Source
const DefaultSnapshotHistoryLimit = 50

DefaultSnapshotHistoryLimit the amount of blocks to look back in state when recursively searching for a valid snapshot

Variables

View Source
var SnapshotHistoryLimitErr = fmt.Errorf("reached the snapshot history limit")

Functions

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 (b *Backend) ExecuteScriptAtBlockHeight(
	ctx context.Context,
	blockHeight uint64,
	script []byte,
	arguments [][]byte,
) ([]byte, error)

func (*Backend) ExecuteScriptAtBlockID

func (b *Backend) ExecuteScriptAtBlockID(
	ctx context.Context,
	blockID flow.Identifier,
	script []byte,
	arguments [][]byte,
) ([]byte, error)

func (*Backend) ExecuteScriptAtLatestBlock

func (b *Backend) ExecuteScriptAtLatestBlock(
	ctx context.Context,
	script []byte,
	arguments [][]byte,
) ([]byte, error)

func (*Backend) GetAccount

func (b *Backend) GetAccount(ctx context.Context, address flow.Address) (*flow.Account, error)

func (*Backend) GetAccountAtBlockHeight

func (b *Backend) GetAccountAtBlockHeight(
	ctx context.Context,
	address flow.Address,
	height uint64,
) (*flow.Account, error)

func (*Backend) GetAccountAtLatestBlock

func (b *Backend) GetAccountAtLatestBlock(ctx context.Context, address flow.Address) (*flow.Account, error)

func (*Backend) GetBlockByHeight

func (b *Backend) GetBlockByHeight(_ context.Context, height uint64) (*flow.Block, error)

func (*Backend) GetBlockByID

func (b *Backend) GetBlockByID(_ context.Context, id flow.Identifier) (*flow.Block, error)

func (*Backend) GetBlockHeaderByHeight

func (b *Backend) GetBlockHeaderByHeight(_ context.Context, height uint64) (*flow.Header, error)

func (*Backend) GetBlockHeaderByID

func (b *Backend) GetBlockHeaderByID(_ context.Context, id flow.Identifier) (*flow.Header, 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 (b *Backend) GetLatestBlock(_ context.Context, isSealed bool) (*flow.Block, error)

func (*Backend) GetLatestBlockHeader

func (b *Backend) GetLatestBlockHeader(_ context.Context, isSealed bool) (*flow.Header, error)

func (*Backend) GetLatestProtocolStateSnapshot added in v0.15.0

func (b *Backend) GetLatestProtocolStateSnapshot(_ context.Context) ([]byte, error)

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) Ping

func (b *Backend) Ping(ctx context.Context) error

Ping responds to requests when the server is up.

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, error)
	InvalidateAccessAPIClient(address string)
	GetExecutionAPIClient(address string) (execution.ExecutionAPIClient, 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, error)

func (*ConnectionFactoryImpl) GetExecutionAPIClient added in v0.14.0

func (cf *ConnectionFactoryImpl) GetExecutionAPIClient(address string) (execution.ExecutionAPIClient, 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

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, error)

func (*ProxyConnectionFactory) GetExecutionAPIClient added in v0.21.0

func (p *ProxyConnectionFactory) GetExecutionAPIClient(address string) (execution.ExecutionAPIClient, error)

type Retry

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

Retry implements a simple retry mechanism for transaction submission.

func (*Retry) Activate

func (r *Retry) Activate() *Retry

func (*Retry) IsActive

func (r *Retry) IsActive() bool

func (*Retry) Notify

func (b *Retry) Notify(signal interface{}) bool

func (*Retry) RegisterTransaction

func (r *Retry) RegisterTransaction(height uint64, tx *flow.TransactionBody)

RegisterTransaction adds a transaction that could possibly be retried

func (*Retry) Retry

func (r *Retry) Retry(height uint64)

func (*Retry) SetBackend

func (r *Retry) SetBackend(b *Backend) *Retry

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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