 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
- Variables
- func NewNetworkAPI(state protocol.State, chainID flow.ChainID, headers storage.Headers, ...) *backendNetwork
- type Backend
- func (b *Backend) GetBlockByHeight(ctx context.Context, height uint64) (*flow.Block, flow.BlockStatus, error)
- func (b *Backend) GetBlockByID(ctx context.Context, id flow.Identifier) (*flow.Block, flow.BlockStatus, error)
- func (b *Backend) GetBlockHeaderByHeight(ctx context.Context, height uint64) (*flow.Header, flow.BlockStatus, error)
- func (b *Backend) GetBlockHeaderByID(ctx 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) 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) GetFullCollectionByID(_ context.Context, colID flow.Identifier) (*flow.Collection, error)
- func (b *Backend) GetLatestBlock(ctx context.Context, isSealed bool) (*flow.Block, flow.BlockStatus, error)
- func (b *Backend) GetLatestBlockHeader(ctx context.Context, isSealed bool) (*flow.Header, flow.BlockStatus, error)
- func (b *Backend) GetLatestProtocolStateSnapshot(_ context.Context) ([]byte, error)
- func (b *Backend) GetNetworkParameters(_ context.Context) accessmodel.NetworkParameters
- func (b *Backend) GetNodeVersionInfo(_ context.Context) (*accessmodel.NodeVersionInfo, error)
- func (b *Backend) GetProtocolStateSnapshotByBlockID(_ context.Context, blockID flow.Identifier) ([]byte, error)
- func (b *Backend) GetProtocolStateSnapshotByHeight(_ context.Context, blockHeight uint64) ([]byte, error)
- func (b *Backend) Ping(ctx context.Context) error
- func (b *Backend) SubscribeBlockDigestsFromLatest(ctx context.Context, blockStatus flow.BlockStatus) subscription.Subscription
- func (b *Backend) SubscribeBlockDigestsFromStartBlockID(ctx context.Context, startBlockID flow.Identifier, ...) subscription.Subscription
- func (b *Backend) SubscribeBlockDigestsFromStartHeight(ctx context.Context, startHeight uint64, blockStatus flow.BlockStatus) subscription.Subscription
- func (b *Backend) SubscribeBlockHeadersFromLatest(ctx context.Context, blockStatus flow.BlockStatus) subscription.Subscription
- func (b *Backend) SubscribeBlockHeadersFromStartBlockID(ctx context.Context, startBlockID flow.Identifier, ...) subscription.Subscription
- func (b *Backend) SubscribeBlockHeadersFromStartHeight(ctx context.Context, startHeight uint64, blockStatus flow.BlockStatus) subscription.Subscription
- func (b *Backend) SubscribeBlocksFromLatest(ctx context.Context, blockStatus flow.BlockStatus) subscription.Subscription
- func (b *Backend) SubscribeBlocksFromStartBlockID(ctx context.Context, startBlockID flow.Identifier, ...) subscription.Subscription
- func (b *Backend) SubscribeBlocksFromStartHeight(ctx context.Context, startHeight uint64, blockStatus flow.BlockStatus) subscription.Subscription
 
- type Config
- type Params
- type ScriptExecutor
- func (s *ScriptExecutor) ExecuteAtBlockHeight(ctx context.Context, script []byte, arguments [][]byte, height uint64) ([]byte, error)
- func (s *ScriptExecutor) GetAccountAtBlockHeight(ctx context.Context, address flow.Address, height uint64) (*flow.Account, error)
- func (s *ScriptExecutor) GetAccountAvailableBalance(ctx context.Context, address flow.Address, height uint64) (uint64, error)
- func (s *ScriptExecutor) GetAccountBalance(ctx context.Context, address flow.Address, height uint64) (uint64, error)
- func (s *ScriptExecutor) GetAccountKey(ctx context.Context, address flow.Address, keyIndex uint32, height uint64) (*flow.AccountPublicKey, error)
- func (s *ScriptExecutor) GetAccountKeys(ctx context.Context, address flow.Address, height uint64) ([]flow.AccountPublicKey, error)
- func (s *ScriptExecutor) Initialize(indexReporter state_synchronization.IndexReporter, ...) error
- func (s *ScriptExecutor) SetMaxCompatibleHeight(height uint64)
- func (s *ScriptExecutor) SetMinCompatibleHeight(height uint64)
 
Constants ¶
const DefaultConnectionPoolSize = 250
    DefaultConnectionPoolSize is the default size for the connection pool to collection and execution nodes
const DefaultSnapshotHistoryLimit = 500
    DefaultSnapshotHistoryLimit the amount of blocks to look back in state when recursively searching for a valid snapshot
Variables ¶
var ErrIncompatibleNodeVersion = errors.New("node version is incompatible with data for block")
    ErrIncompatibleNodeVersion indicates that node version is incompatible with the block version
Functions ¶
func NewNetworkAPI ¶ added in v0.28.0
func NewNetworkAPI( state protocol.State, chainID flow.ChainID, headers storage.Headers, 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
Types ¶
type Backend ¶
type Backend struct {
	accounts.Accounts
	events.Events
	scripts.Scripts
	transactions.Transactions
	txstream.TransactionStream
	BlockTracker tracker.BlockTracker
	// 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 (*Backend) GetBlockByHeight ¶
func (*Backend) GetBlockByID ¶
func (b *Backend) GetBlockByID(ctx context.Context, id flow.Identifier) (*flow.Block, flow.BlockStatus, error)
func (*Backend) GetBlockHeaderByHeight ¶
func (*Backend) GetBlockHeaderByID ¶
func (b *Backend) GetBlockHeaderByID(ctx 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) 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) GetFullCollectionByID ¶ added in v0.33.26
func (b *Backend) GetFullCollectionByID(_ context.Context, colID flow.Identifier) (*flow.Collection, 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) accessmodel.NetworkParameters
func (*Backend) GetNodeVersionInfo ¶ added in v0.31.0
func (b *Backend) GetNodeVersionInfo(_ context.Context) (*accessmodel.NodeVersionInfo, error)
GetNodeVersionInfo returns node version information such as semver, commit, sporkID, protocolVersion, etc
func (*Backend) GetProtocolStateSnapshotByBlockID ¶ added in v0.33.1
func (b *Backend) GetProtocolStateSnapshotByBlockID(_ context.Context, blockID flow.Identifier) ([]byte, error)
GetProtocolStateSnapshotByBlockID returns serializable Snapshot for a block, by blockID. The requested block must be finalized, otherwise an error is returned. Expected errors during normal operation:
- status.Error[codes.NotFound] - No block with the given ID was found
- status.Error[codes.InvalidArgument] - Block ID is for an orphaned block and will never have a valid snapshot
- status.Error[codes.FailedPrecondition] - A block was found, but it is not finalized and is above the finalized height. The block may or may not be finalized in the future; the client can retry later.
func (*Backend) GetProtocolStateSnapshotByHeight ¶ added in v0.33.1
func (b *Backend) GetProtocolStateSnapshotByHeight(_ context.Context, blockHeight uint64) ([]byte, error)
GetProtocolStateSnapshotByHeight returns serializable Snapshot by block height. The block must be finalized (otherwise the by-height query is ambiguous). Expected errors during normal operation:
- status.Error[codes.NotFound] - No block with the given height was found. The block height may or may not be finalized in the future; the client can retry later.
func (*Backend) SubscribeBlockDigestsFromLatest ¶ added in v0.33.30
func (b *Backend) SubscribeBlockDigestsFromLatest(ctx context.Context, blockStatus flow.BlockStatus) subscription.Subscription
SubscribeBlockDigestsFromLatest streams finalized or sealed lightweight block starting at the latest sealed block, up until the latest available block. Once the latest is reached, the stream will remain open and responses are sent for each new block as it becomes available.
Each lightweight block are filtered by the provided block status, and only those blocks that match the status are returned.
Parameters: - ctx: Context for the operation. - blockStatus: The status of the block, which could be only BlockStatusSealed or BlockStatusFinalized.
If invalid parameters will be supplied SubscribeBlockDigestsFromLatest will return a failed subscription.
func (*Backend) SubscribeBlockDigestsFromStartBlockID ¶ added in v0.33.30
func (b *Backend) SubscribeBlockDigestsFromStartBlockID(ctx context.Context, startBlockID flow.Identifier, blockStatus flow.BlockStatus) subscription.Subscription
SubscribeBlockDigestsFromStartBlockID streams finalized or sealed lightweight block starting at the requested start block id, up until the latest available block. Once the latest is reached, the stream will remain open and responses are sent for each new block as it becomes available.
Each lightweight block are filtered by the provided block status, and only those blocks that match the status are returned.
Parameters: - ctx: Context for the operation. - startBlockID: The identifier of the starting block. - blockStatus: The status of the block, which could be only BlockStatusSealed or BlockStatusFinalized.
If invalid parameters will be supplied SubscribeBlockDigestsFromStartBlockID will return a failed subscription.
func (*Backend) SubscribeBlockDigestsFromStartHeight ¶ added in v0.33.30
func (b *Backend) SubscribeBlockDigestsFromStartHeight(ctx context.Context, startHeight uint64, blockStatus flow.BlockStatus) subscription.Subscription
SubscribeBlockDigestsFromStartHeight streams finalized or sealed lightweight block starting at the requested start block height, up until the latest available block. Once the latest is reached, the stream will remain open and responses are sent for each new block as it becomes available.
Each lightweight block are filtered by the provided block status, and only those blocks that match the status are returned.
Parameters: - ctx: Context for the operation. - startHeight: The height of the starting block. - blockStatus: The status of the block, which could be only BlockStatusSealed or BlockStatusFinalized.
If invalid parameters will be supplied SubscribeBlockDigestsFromStartHeight will return a failed subscription.
func (*Backend) SubscribeBlockHeadersFromLatest ¶ added in v0.33.30
func (b *Backend) SubscribeBlockHeadersFromLatest(ctx context.Context, blockStatus flow.BlockStatus) subscription.Subscription
SubscribeBlockHeadersFromLatest streams finalized or sealed block headers starting at the latest sealed block, up until the latest available block header. Once the latest is reached, the stream will remain open and responses are sent for each new block header as it becomes available.
Each block header are filtered by the provided block status, and only those block headers that match the status are returned.
Parameters: - ctx: Context for the operation. - blockStatus: The status of the block, which could be only BlockStatusSealed or BlockStatusFinalized.
If invalid parameters will be supplied SubscribeBlockHeadersFromLatest will return a failed subscription.
func (*Backend) SubscribeBlockHeadersFromStartBlockID ¶ added in v0.33.30
func (b *Backend) SubscribeBlockHeadersFromStartBlockID(ctx context.Context, startBlockID flow.Identifier, blockStatus flow.BlockStatus) subscription.Subscription
SubscribeBlockHeadersFromStartBlockID streams finalized or sealed block headers starting at the requested start block id, up until the latest available block header. Once the latest is reached, the stream will remain open and responses are sent for each new block header as it becomes available.
Each block header are filtered by the provided block status, and only those block headers that match the status are returned.
Parameters: - ctx: Context for the operation. - startBlockID: The identifier of the starting block. - blockStatus: The status of the block, which could be only BlockStatusSealed or BlockStatusFinalized.
If invalid parameters will be supplied SubscribeBlockHeadersFromStartBlockID will return a failed subscription.
func (*Backend) SubscribeBlockHeadersFromStartHeight ¶ added in v0.33.30
func (b *Backend) SubscribeBlockHeadersFromStartHeight(ctx context.Context, startHeight uint64, blockStatus flow.BlockStatus) subscription.Subscription
SubscribeBlockHeadersFromStartHeight streams finalized or sealed block headers starting at the requested start block height, up until the latest available block header. Once the latest is reached, the stream will remain open and responses are sent for each new block header as it becomes available.
Each block header are filtered by the provided block status, and only those block headers that match the status are returned.
Parameters: - ctx: Context for the operation. - startHeight: The height of the starting block. - blockStatus: The status of the block, which could be only BlockStatusSealed or BlockStatusFinalized.
If invalid parameters will be supplied SubscribeBlockHeadersFromStartHeight will return a failed subscription.
func (*Backend) SubscribeBlocksFromLatest ¶ added in v0.33.30
func (b *Backend) SubscribeBlocksFromLatest(ctx context.Context, blockStatus flow.BlockStatus) subscription.Subscription
SubscribeBlocksFromLatest subscribes to the finalized or sealed blocks starting at the latest sealed block, up until the latest available block. Once the latest is reached, the stream will remain open and responses are sent for each new block as it becomes available.
Each block is filtered by the provided block status, and only those blocks that match the status are returned.
Parameters: - ctx: Context for the operation. - blockStatus: The status of the block, which could be only BlockStatusSealed or BlockStatusFinalized.
If invalid parameters will be supplied SubscribeBlocksFromLatest will return a failed subscription.
func (*Backend) SubscribeBlocksFromStartBlockID ¶ added in v0.33.30
func (b *Backend) SubscribeBlocksFromStartBlockID(ctx context.Context, startBlockID flow.Identifier, blockStatus flow.BlockStatus) subscription.Subscription
SubscribeBlocksFromStartBlockID subscribes to the finalized or sealed blocks starting at the requested start block id, up until the latest available block. Once the latest is reached, the stream will remain open and responses are sent for each new block as it becomes available.
Each block is filtered by the provided block status, and only those blocks that match the status are returned.
Parameters: - ctx: Context for the operation. - startBlockID: The identifier of the starting block. - blockStatus: The status of the block, which could be only BlockStatusSealed or BlockStatusFinalized.
If invalid parameters will be supplied SubscribeBlocksFromStartBlockID will return a failed subscription.
func (*Backend) SubscribeBlocksFromStartHeight ¶ added in v0.33.30
func (b *Backend) SubscribeBlocksFromStartHeight(ctx context.Context, startHeight uint64, blockStatus flow.BlockStatus) subscription.Subscription
SubscribeBlocksFromStartHeight subscribes to the finalized or sealed blocks starting at the requested start block height, up until the latest available block. Once the latest is reached, the stream will remain open and responses are sent for each new block as it becomes available.
Each block is filtered by the provided block status, and only those blocks that match the status are returned.
Parameters: - ctx: Context for the operation. - startHeight: The height of the starting block. - blockStatus: The status of the block, which could be only BlockStatusSealed or BlockStatusFinalized.
If invalid parameters will be supplied SubscribeBlocksFromStartHeight will return a failed subscription.
type Config ¶ added in v0.32.0
type Config struct {
	AccessConfig              connection.Config               // access API GRPC client config
	ExecutionConfig           connection.Config               // execution API GRPC client config
	CollectionConfig          connection.Config               // collection API GRPC client config
	ConnectionPoolSize        uint                            // size of the cache for storing collection and execution connections
	MaxHeightRange            uint                            // max size of height range requests
	PreferredExecutionNodeIDs []string                        // preferred list of upstream execution node IDs
	FixedExecutionNodeIDs     []string                        // fixed list of execution node IDs to choose from if no node ID can be chosen from the PreferredExecutionNodeIDs
	CircuitBreakerConfig      connection.CircuitBreakerConfig // the configuration for circuit breaker
	ScriptExecutionMode       string                          // the mode in which scripts are executed
	EventQueryMode            string                          // the mode in which events are queried
	TxResultQueryMode         string                          // the mode in which tx results are queried
}
    Config defines the configurable options for creating Backend
type Params ¶ added in v0.32.0
type Params struct {
	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
	TxResultErrorMessages    storage.TransactionResultErrorMessages
	ChainID                  flow.ChainID
	AccessMetrics            module.AccessMetrics
	ConnFactory              connection.ConnectionFactory
	RetryEnabled             bool
	MaxHeightRange           uint
	Log                      zerolog.Logger
	SnapshotHistoryLimit     int
	Communicator             node_communicator.Communicator
	TxResultCacheSize        uint
	ScriptExecutor           execution.ScriptExecutor
	ScriptExecutionMode      query_mode.IndexQueryMode
	CheckPayerBalanceMode    validator.PayerBalanceMode
	EventQueryMode           query_mode.IndexQueryMode
	BlockTracker             tracker.BlockTracker
	SubscriptionHandler      *subscription.SubscriptionHandler
	MaxScriptAndArgumentSize uint
	EventsIndex                *index.EventsIndex
	TxResultQueryMode          query_mode.IndexQueryMode
	TxResultsIndex             *index.TransactionResultsIndex
	LastFullBlockHeight        *counters.PersistentStrictMonotonicCounter
	IndexReporter              state_synchronization.IndexReporter
	VersionControl             *version.VersionControl
	ExecNodeIdentitiesProvider *rpc.ExecutionNodeIdentitiesProvider
	TxErrorMessageProvider     error_messages.Provider
	ScheduledCallbacksEnabled  bool
}
    type ScriptExecutor ¶ added in v0.32.2
type ScriptExecutor struct {
	// contains filtered or unexported fields
}
    func NewScriptExecutor ¶ added in v0.32.2
func NewScriptExecutor(log zerolog.Logger, minHeight, maxHeight uint64) *ScriptExecutor
func (*ScriptExecutor) ExecuteAtBlockHeight ¶ added in v0.32.2
func (s *ScriptExecutor) ExecuteAtBlockHeight(ctx context.Context, script []byte, arguments [][]byte, height uint64) ([]byte, error)
ExecuteAtBlockHeight executes provided script at the provided block height against a local execution state.
Expected errors:
- storage.ErrNotFound if the register or block height is not found
- storage.ErrHeightNotIndexed if the ScriptExecutor is not initialized, or if the height is not indexed yet, or if the height is before the lowest indexed height.
- ErrIncompatibleNodeVersion if the block height is not compatible with the node version.
func (*ScriptExecutor) GetAccountAtBlockHeight ¶ added in v0.32.2
func (s *ScriptExecutor) GetAccountAtBlockHeight(ctx context.Context, address flow.Address, height uint64) (*flow.Account, error)
GetAccountAtBlockHeight returns the account at the provided block height from a local execution state.
Expected errors:
- storage.ErrNotFound if the account or block height is not found
- storage.ErrHeightNotIndexed if the ScriptExecutor is not initialized, or if the height is not indexed yet, or if the height is before the lowest indexed height.
- ErrIncompatibleNodeVersion if the block height is not compatible with the node version.
func (*ScriptExecutor) GetAccountAvailableBalance ¶ added in v0.36.1
func (s *ScriptExecutor) GetAccountAvailableBalance(ctx context.Context, address flow.Address, height uint64) (uint64, error)
GetAccountAvailableBalance returns an available balance of Flow account by the provided address and block height. Expected errors:
- Script execution related errors
- storage.ErrHeightNotIndexed if the ScriptExecutor is not initialized, or if the height is not indexed yet, or if the height is before the lowest indexed height.
- ErrIncompatibleNodeVersion if the block height is not compatible with the node version.
func (*ScriptExecutor) GetAccountBalance ¶ added in v0.35.17
func (s *ScriptExecutor) GetAccountBalance(ctx context.Context, address flow.Address, height uint64) (uint64, error)
GetAccountBalance returns a balance of Flow account by the provided address and block height. Expected errors:
- Script execution related errors
- storage.ErrHeightNotIndexed if the ScriptExecutor is not initialized, or if the height is not indexed yet, or if the height is before the lowest indexed height.
- ErrIncompatibleNodeVersion if the block height is not compatible with the node version.
func (*ScriptExecutor) GetAccountKey ¶ added in v0.36.1
func (s *ScriptExecutor) GetAccountKey(ctx context.Context, address flow.Address, keyIndex uint32, height uint64) (*flow.AccountPublicKey, error)
GetAccountKey returns Expected errors:
- Script execution related errors
- storage.ErrHeightNotIndexed if the ScriptExecutor is not initialized, or if the height is not indexed yet, or if the height is before the lowest indexed height.
- ErrIncompatibleNodeVersion if the block height is not compatible with the node version.
func (*ScriptExecutor) GetAccountKeys ¶ added in v0.35.17
func (s *ScriptExecutor) GetAccountKeys(ctx context.Context, address flow.Address, height uint64) ([]flow.AccountPublicKey, error)
GetAccountKeys returns a public key of Flow account by the provided address, block height and index. Expected errors:
- Script execution related errors
- storage.ErrHeightNotIndexed if the ScriptExecutor is not initialized, or if the height is not indexed yet, or if the height is before the lowest indexed height.
- ErrIncompatibleNodeVersion if the block height is not compatible with the node version.
func (*ScriptExecutor) Initialize ¶ added in v0.33.9
func (s *ScriptExecutor) Initialize( indexReporter state_synchronization.IndexReporter, scriptExecutor *execution.Scripts, versionControl *version.VersionControl, ) error
Initialize initializes the indexReporter and script executor This method can be called at any time after the ScriptExecutor object is created. Any requests made to the other methods will return storage.ErrHeightNotIndexed until this method is called.
func (*ScriptExecutor) SetMaxCompatibleHeight ¶ added in v0.32.10
func (s *ScriptExecutor) SetMaxCompatibleHeight(height uint64)
SetMaxCompatibleHeight sets the highest block height (inclusive) that can be queried using local execution Use this to limit the executable block range supported by the node's current software version.
func (*ScriptExecutor) SetMinCompatibleHeight ¶ added in v0.32.10
func (s *ScriptExecutor) SetMinCompatibleHeight(height uint64)
SetMinCompatibleHeight sets the lowest block height (inclusive) that can be queried using local execution Use this to limit the executable block range supported by the node's current software version.