backend

package
v0.13.1-patch.3 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: AGPL-3.0 Imports: 24 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

Backends 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,
	executionRPC execproto.ExecutionAPIClient,
	collectionRPC accessproto.AccessAPIClient,
	historicalAccessNodes []accessproto.AccessAPIClient,
	blocks storage.Blocks,
	headers storage.Headers,
	collections storage.Collections,
	transactions storage.Transactions,
	executionReceipts storage.ExecutionReceipts,
	chainID flow.ChainID,
	transactionMetrics module.TransactionMetrics,
	connFactory ConnectionFactory,
	retryEnabled bool,
	log zerolog.Logger,
) *Backend

func (*Backend) DeriveTransactionStatus

func (b *Backend) DeriveTransactionStatus(
	tx *flow.TransactionBody,
	executed bool,
) (flow.TransactionStatus, error)

DeriveTransactionStatus derives the transaction status based on current protocol state

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

type ConnectionFactory interface {
	GetAccessAPIClient(address string) (access.AccessAPIClient, io.Closer, error)
	GetExecutionAPIClient(address string) (execution.ExecutionAPIClient, io.Closer, error)
}

ConnectionFactory is used to create an access api client

type ConnectionFactoryImpl

type ConnectionFactoryImpl struct {
	CollectionGRPCPort uint
	ExecutionGRPCPort  uint
}

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)

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