access

package
v0.37.0-crescendo-RC9 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: AGPL-3.0 Imports: 30 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownReferenceBlock = errors.New("unknown reference block")

ErrUnknownReferenceBlock indicates that a transaction references an unknown block.

Functions

func IsInsufficientBalanceError added in v0.36.2

func IsInsufficientBalanceError(err error) bool

func TransactionResultToMessage

func TransactionResultToMessage(result *TransactionResult) *access.TransactionResultResponse

func TransactionResultsToMessage added in v0.24.11

func TransactionResultsToMessage(results []*TransactionResult) *access.TransactionResultsResponse

func WithBlockSignerDecoder added in v0.26.17

func WithBlockSignerDecoder(signerIndicesDecoder hotstuff.BlockSignerDecoder) func(*Handler)

WithBlockSignerDecoder configures the Handler to decode signer indices via the provided hotstuff.BlockSignerDecoder

func WithIndexReporter added in v0.33.30

func WithIndexReporter(indexReporter state_synchronization.IndexReporter) func(*Handler)

WithIndexReporter configures the Handler to work with index reporter

Types

type API

type API interface {
	Ping(ctx context.Context) error
	GetNetworkParameters(ctx context.Context) NetworkParameters
	GetNodeVersionInfo(ctx context.Context) (*NodeVersionInfo, error)

	GetLatestBlockHeader(ctx context.Context, isSealed bool) (*flow.Header, flow.BlockStatus, error)
	GetBlockHeaderByHeight(ctx context.Context, height uint64) (*flow.Header, flow.BlockStatus, error)
	GetBlockHeaderByID(ctx context.Context, id flow.Identifier) (*flow.Header, flow.BlockStatus, error)

	GetLatestBlock(ctx context.Context, isSealed bool) (*flow.Block, flow.BlockStatus, error)
	GetBlockByHeight(ctx context.Context, height uint64) (*flow.Block, flow.BlockStatus, error)
	GetBlockByID(ctx context.Context, id flow.Identifier) (*flow.Block, flow.BlockStatus, error)

	GetCollectionByID(ctx context.Context, id flow.Identifier) (*flow.LightCollection, error)
	GetFullCollectionByID(ctx context.Context, id flow.Identifier) (*flow.Collection, error)

	SendTransaction(ctx context.Context, tx *flow.TransactionBody) error
	GetTransaction(ctx context.Context, id flow.Identifier) (*flow.TransactionBody, error)
	GetTransactionsByBlockID(ctx context.Context, blockID flow.Identifier) ([]*flow.TransactionBody, error)
	GetTransactionResult(ctx context.Context, id flow.Identifier, blockID flow.Identifier, collectionID flow.Identifier, requiredEventEncodingVersion entities.EventEncodingVersion) (*TransactionResult, error)
	GetTransactionResultByIndex(ctx context.Context, blockID flow.Identifier, index uint32, requiredEventEncodingVersion entities.EventEncodingVersion) (*TransactionResult, error)
	GetTransactionResultsByBlockID(ctx context.Context, blockID flow.Identifier, requiredEventEncodingVersion entities.EventEncodingVersion) ([]*TransactionResult, error)
	GetSystemTransaction(ctx context.Context, blockID flow.Identifier) (*flow.TransactionBody, error)
	GetSystemTransactionResult(ctx context.Context, blockID flow.Identifier, requiredEventEncodingVersion entities.EventEncodingVersion) (*TransactionResult, error)

	GetAccount(ctx context.Context, address flow.Address) (*flow.Account, error)
	GetAccountAtLatestBlock(ctx context.Context, address flow.Address) (*flow.Account, error)
	GetAccountAtBlockHeight(ctx context.Context, address flow.Address, height uint64) (*flow.Account, error)

	GetAccountBalanceAtLatestBlock(ctx context.Context, address flow.Address) (uint64, error)
	GetAccountBalanceAtBlockHeight(ctx context.Context, address flow.Address, height uint64) (uint64, error)

	GetAccountKeyAtLatestBlock(ctx context.Context, address flow.Address, keyIndex uint32) (*flow.AccountPublicKey, error)
	GetAccountKeyAtBlockHeight(ctx context.Context, address flow.Address, keyIndex uint32, height uint64) (*flow.AccountPublicKey, error)
	GetAccountKeysAtLatestBlock(ctx context.Context, address flow.Address) ([]flow.AccountPublicKey, error)
	GetAccountKeysAtBlockHeight(ctx context.Context, address flow.Address, height uint64) ([]flow.AccountPublicKey, error)

	ExecuteScriptAtLatestBlock(ctx context.Context, script []byte, arguments [][]byte) ([]byte, error)
	ExecuteScriptAtBlockHeight(ctx context.Context, blockHeight uint64, script []byte, arguments [][]byte) ([]byte, error)
	ExecuteScriptAtBlockID(ctx context.Context, blockID flow.Identifier, script []byte, arguments [][]byte) ([]byte, error)

	GetEventsForHeightRange(ctx context.Context, eventType string, startHeight, endHeight uint64, requiredEventEncodingVersion entities.EventEncodingVersion) ([]flow.BlockEvents, error)
	GetEventsForBlockIDs(ctx context.Context, eventType string, blockIDs []flow.Identifier, requiredEventEncodingVersion entities.EventEncodingVersion) ([]flow.BlockEvents, error)

	GetLatestProtocolStateSnapshot(ctx context.Context) ([]byte, error)
	GetProtocolStateSnapshotByBlockID(ctx context.Context, blockID flow.Identifier) ([]byte, error)
	GetProtocolStateSnapshotByHeight(ctx context.Context, blockHeight uint64) ([]byte, error)

	GetExecutionResultForBlockID(ctx context.Context, blockID flow.Identifier) (*flow.ExecutionResult, error)
	GetExecutionResultByID(ctx context.Context, id flow.Identifier) (*flow.ExecutionResult, error)

	// 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.
	SubscribeBlocksFromStartBlockID(ctx context.Context, startBlockID flow.Identifier, 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.
	SubscribeBlocksFromStartHeight(ctx context.Context, startHeight uint64, 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.
	SubscribeBlocksFromLatest(ctx context.Context, 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.
	SubscribeBlockHeadersFromStartBlockID(ctx context.Context, startBlockID flow.Identifier, 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.
	SubscribeBlockHeadersFromStartHeight(ctx context.Context, startHeight uint64, 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.
	SubscribeBlockHeadersFromLatest(ctx context.Context, 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.
	SubscribeBlockDigestsFromStartBlockID(ctx context.Context, startBlockID flow.Identifier, 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.
	SubscribeBlockDigestsFromStartHeight(ctx context.Context, startHeight uint64, 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.
	SubscribeBlockDigestsFromLatest(ctx context.Context, blockStatus flow.BlockStatus) subscription.Subscription
	// SubscribeTransactionStatuses streams transaction statuses starting from the reference block saved in the
	// transaction itself until the block containing the transaction becomes sealed or expired. When the transaction
	// status becomes TransactionStatusSealed or TransactionStatusExpired, the subscription will automatically shut down.
	SubscribeTransactionStatuses(ctx context.Context, tx *flow.TransactionBody, requiredEventEncodingVersion entities.EventEncodingVersion) subscription.Subscription
}

API provides all public-facing functionality of the Flow Access API.

type Blocks

type Blocks interface {
	HeaderByID(id flow.Identifier) (*flow.Header, error)
	FinalizedHeader() (*flow.Header, error)
	SealedHeader() (*flow.Header, error)
}

type DuplicatedSignatureError added in v0.18.4

type DuplicatedSignatureError struct {
	Address  flow.Address
	KeyIndex uint32
}

DuplicatedSignatureError indicates that two signatures havs been provided for a key (combination of account and key index)

func (DuplicatedSignatureError) Error added in v0.18.4

func (e DuplicatedSignatureError) Error() string

type ExpiredTransactionError

type ExpiredTransactionError struct {
	RefHeight, FinalHeight uint64
}

ExpiredTransactionError indicates that a transaction has expired.

func (ExpiredTransactionError) Error

func (e ExpiredTransactionError) Error() string

type Handler

type Handler struct {
	subscription.StreamingData
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(
	api API,
	chain flow.Chain,
	finalizedHeader module.FinalizedHeaderCache,
	me module.Local,
	maxStreams uint32,
	options ...HandlerOption,
) *Handler

func (*Handler) ExecuteScriptAtBlockHeight

func (h *Handler) ExecuteScriptAtBlockHeight(
	ctx context.Context,
	req *access.ExecuteScriptAtBlockHeightRequest,
) (*access.ExecuteScriptResponse, error)

ExecuteScriptAtBlockHeight executes a script at a specific block height.

func (*Handler) ExecuteScriptAtBlockID

func (h *Handler) ExecuteScriptAtBlockID(
	ctx context.Context,
	req *access.ExecuteScriptAtBlockIDRequest,
) (*access.ExecuteScriptResponse, error)

ExecuteScriptAtBlockID executes a script at a specific block ID.

func (*Handler) ExecuteScriptAtLatestBlock

func (h *Handler) ExecuteScriptAtLatestBlock(
	ctx context.Context,
	req *access.ExecuteScriptAtLatestBlockRequest,
) (*access.ExecuteScriptResponse, error)

ExecuteScriptAtLatestBlock executes a script at a the latest block.

func (*Handler) GetAccount

GetAccount returns an account by address at the latest sealed block.

func (*Handler) GetAccountAtBlockHeight

func (h *Handler) GetAccountAtBlockHeight(
	ctx context.Context,
	req *access.GetAccountAtBlockHeightRequest,
) (*access.AccountResponse, error)

GetAccountAtBlockHeight returns an account by address at the given block height.

func (*Handler) GetAccountAtLatestBlock

func (h *Handler) GetAccountAtLatestBlock(
	ctx context.Context,
	req *access.GetAccountAtLatestBlockRequest,
) (*access.AccountResponse, error)

GetAccountAtLatestBlock returns an account by address at the latest sealed block.

func (*Handler) GetAccountBalanceAtBlockHeight added in v0.36.1

func (h *Handler) GetAccountBalanceAtBlockHeight(
	ctx context.Context,
	req *access.GetAccountBalanceAtBlockHeightRequest,
) (*access.AccountBalanceResponse, error)

func (*Handler) GetAccountBalanceAtLatestBlock added in v0.36.1

func (h *Handler) GetAccountBalanceAtLatestBlock(
	ctx context.Context,
	req *access.GetAccountBalanceAtLatestBlockRequest,
) (*access.AccountBalanceResponse, error)

GetAccountBalanceAtLatestBlock returns an account balance by address at the latest sealed block.

Expected errors during normal operation: - codes.InvalidArgument - if invalid account address provided. - codes.Internal - if failed to get account from the execution node or failed to convert account message.

func (*Handler) GetAccountKeyAtBlockHeight added in v0.36.1

func (h *Handler) GetAccountKeyAtBlockHeight(
	ctx context.Context,
	req *access.GetAccountKeyAtBlockHeightRequest,
) (*access.AccountKeyResponse, error)

GetAccountKeyAtBlockHeight returns an account public keys by address and key index at the given block height. GetAccountKeyAtLatestBlock returns an account public key by address and key index at the latest sealed block.

Expected errors during normal operation: - codes.InvalidArgument - if invalid account address provided. - codes.Internal - if failed to get account from the execution node, ailed to convert account message or failed to encode account key.

func (*Handler) GetAccountKeyAtLatestBlock added in v0.36.1

func (h *Handler) GetAccountKeyAtLatestBlock(
	ctx context.Context,
	req *access.GetAccountKeyAtLatestBlockRequest,
) (*access.AccountKeyResponse, error)

GetAccountKeyAtLatestBlock returns an account public key by address and key index at the latest sealed block.

Expected errors during normal operation: - codes.InvalidArgument - if invalid account address provided. - codes.Internal - if failed to get account from the execution node, ailed to convert account message or failed to encode account key.

func (*Handler) GetAccountKeysAtBlockHeight added in v0.36.1

func (h *Handler) GetAccountKeysAtBlockHeight(
	ctx context.Context,
	req *access.GetAccountKeysAtBlockHeightRequest,
) (*access.AccountKeysResponse, error)

GetAccountKeysAtBlockHeight returns an account public keys by address at the given block height. GetAccountKeyAtLatestBlock returns an account public key by address and key index at the latest sealed block.

Expected errors during normal operation: - codes.InvalidArgument - if invalid account address provided. - codes.Internal - if failed to get account from the execution node, ailed to convert account message or failed to encode account key.

func (*Handler) GetAccountKeysAtLatestBlock added in v0.36.1

func (h *Handler) GetAccountKeysAtLatestBlock(
	ctx context.Context,
	req *access.GetAccountKeysAtLatestBlockRequest,
) (*access.AccountKeysResponse, error)

GetAccountKeysAtLatestBlock returns an account public keys by address at the latest sealed block. GetAccountKeyAtLatestBlock returns an account public key by address and key index at the latest sealed block.

Expected errors during normal operation: - codes.InvalidArgument - if invalid account address provided. - codes.Internal - if failed to get account from the execution node, ailed to convert account message or failed to encode account key.

func (*Handler) GetBlockByHeight

func (h *Handler) GetBlockByHeight(
	ctx context.Context,
	req *access.GetBlockByHeightRequest,
) (*access.BlockResponse, error)

GetBlockByHeight gets a block by height.

func (*Handler) GetBlockByID

func (h *Handler) GetBlockByID(
	ctx context.Context,
	req *access.GetBlockByIDRequest,
) (*access.BlockResponse, error)

GetBlockByID gets a block by ID.

func (*Handler) GetBlockHeaderByHeight

func (h *Handler) GetBlockHeaderByHeight(
	ctx context.Context,
	req *access.GetBlockHeaderByHeightRequest,
) (*access.BlockHeaderResponse, error)

GetBlockHeaderByHeight gets a block header by height.

func (*Handler) GetBlockHeaderByID

func (h *Handler) GetBlockHeaderByID(
	ctx context.Context,
	req *access.GetBlockHeaderByIDRequest,
) (*access.BlockHeaderResponse, error)

GetBlockHeaderByID gets a block header by ID.

func (*Handler) GetCollectionByID

func (h *Handler) GetCollectionByID(
	ctx context.Context,
	req *access.GetCollectionByIDRequest,
) (*access.CollectionResponse, error)

GetCollectionByID gets a collection by ID.

func (*Handler) GetEventsForBlockIDs

func (h *Handler) GetEventsForBlockIDs(
	ctx context.Context,
	req *access.GetEventsForBlockIDsRequest,
) (*access.EventsResponse, error)

GetEventsForBlockIDs returns events matching a set of block IDs.

func (*Handler) GetEventsForHeightRange

func (h *Handler) GetEventsForHeightRange(
	ctx context.Context,
	req *access.GetEventsForHeightRangeRequest,
) (*access.EventsResponse, error)

GetEventsForHeightRange returns events matching a query.

func (*Handler) GetExecutionResultByID added in v0.32.0

GetExecutionResultByID returns the execution result for the given ID.

func (*Handler) GetExecutionResultForBlockID added in v0.21.0

GetExecutionResultForBlockID returns the latest received execution result for the given block ID. AN might receive multiple receipts with conflicting results for unsealed blocks. If this case happens, since AN is not able to determine which result is the correct one until the block is sealed, it has to pick one result to respond to this query. For now, we return the result from the latest received receipt.

func (*Handler) GetFullCollectionByID added in v0.33.26

func (h *Handler) GetFullCollectionByID(
	ctx context.Context,
	req *access.GetFullCollectionByIDRequest,
) (*access.FullCollectionResponse, error)

func (*Handler) GetLatestBlock

func (h *Handler) GetLatestBlock(
	ctx context.Context,
	req *access.GetLatestBlockRequest,
) (*access.BlockResponse, error)

GetLatestBlock gets the latest sealed block.

func (*Handler) GetLatestBlockHeader

func (h *Handler) GetLatestBlockHeader(
	ctx context.Context,
	req *access.GetLatestBlockHeaderRequest,
) (*access.BlockHeaderResponse, error)

GetLatestBlockHeader gets the latest sealed block header.

func (*Handler) GetLatestProtocolStateSnapshot added in v0.14.4

GetLatestProtocolStateSnapshot returns the latest serializable Snapshot

func (*Handler) GetNodeVersionInfo added in v0.31.0

GetNodeVersionInfo gets node version information such as semver, commit, sporkID, protocolVersion, etc

func (*Handler) GetProtocolStateSnapshotByBlockID added in v0.33.1

GetProtocolStateSnapshotByBlockID returns serializable Snapshot by blockID

func (*Handler) GetProtocolStateSnapshotByHeight added in v0.33.1

GetProtocolStateSnapshotByHeight returns serializable Snapshot by block height

func (*Handler) GetSystemTransaction added in v0.33.1

func (h *Handler) GetSystemTransaction(
	ctx context.Context,
	req *access.GetSystemTransactionRequest,
) (*access.TransactionResponse, error)

func (*Handler) GetSystemTransactionResult added in v0.33.1

func (h *Handler) GetSystemTransactionResult(
	ctx context.Context,
	req *access.GetSystemTransactionResultRequest,
) (*access.TransactionResultResponse, error)

func (*Handler) GetTransaction

func (h *Handler) GetTransaction(
	ctx context.Context,
	req *access.GetTransactionRequest,
) (*access.TransactionResponse, error)

GetTransaction gets a transaction by ID.

func (*Handler) GetTransactionResult

func (h *Handler) GetTransactionResult(
	ctx context.Context,
	req *access.GetTransactionRequest,
) (*access.TransactionResultResponse, error)

GetTransactionResult gets a transaction by ID.

func (*Handler) GetTransactionResultByIndex added in v0.24.8

func (h *Handler) GetTransactionResultByIndex(
	ctx context.Context,
	req *access.GetTransactionByIndexRequest,
) (*access.TransactionResultResponse, error)

GetTransactionResultByIndex gets a transaction at a specific index for in a block that is executed, pending or finalized transactions return errors

func (*Handler) GetTransactionResultsByBlockID added in v0.24.11

func (h *Handler) GetTransactionResultsByBlockID(
	ctx context.Context,
	req *access.GetTransactionsByBlockIDRequest,
) (*access.TransactionResultsResponse, error)

func (*Handler) GetTransactionsByBlockID added in v0.24.11

func (h *Handler) GetTransactionsByBlockID(
	ctx context.Context,
	req *access.GetTransactionsByBlockIDRequest,
) (*access.TransactionsResponse, error)

func (*Handler) Ping

Ping the Access API server for a response.

func (*Handler) SendAndSubscribeTransactionStatuses added in v0.33.30

SendAndSubscribeTransactionStatuses streams transaction statuses starting from the reference block saved in the transaction itself until the block containing the transaction becomes sealed or expired. When the transaction status becomes TransactionStatusSealed or TransactionStatusExpired, the subscription will automatically shut down.

func (*Handler) SendTransaction

SendTransaction submits a transaction to the network.

func (*Handler) SubscribeBlockDigestsFromLatest added in v0.33.30

SubscribeBlockDigestsFromLatest handles subscription requests for lightweight block started from latest sealed block. It takes a SubscribeBlockDigestsFromLatestRequest and an AccessAPI_SubscribeBlockDigestsFromLatestServer stream as input. The handler manages the subscription to block updates and sends the subscribed block header information to the client via the provided stream.

Expected errors during normal operation: - codes.InvalidArgument - if unknown block status provided. - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block to message or could not send response.

func (*Handler) SubscribeBlockDigestsFromStartBlockID added in v0.33.30

SubscribeBlockDigestsFromStartBlockID streams finalized or sealed lightweight block starting at the requested block id. It takes a SubscribeBlockDigestsFromStartBlockIDRequest and an AccessAPI_SubscribeBlockDigestsFromStartBlockIDServer stream as input.

Expected errors during normal operation: - codes.InvalidArgument - if invalid startBlockID provided or unknown block status provided, - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block to message or could not send response.

func (*Handler) SubscribeBlockDigestsFromStartHeight added in v0.33.30

SubscribeBlockDigestsFromStartHeight handles subscription requests for lightweight blocks started from block height. It takes a SubscribeBlockDigestsFromStartHeightRequest and an AccessAPI_SubscribeBlockDigestsFromStartHeightServer stream as input. The handler manages the subscription to block updates and sends the subscribed block information to the client via the provided stream.

Expected errors during normal operation: - codes.InvalidArgument - if unknown block status provided. - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block to message or could not send response.

func (*Handler) SubscribeBlockHeadersFromLatest added in v0.33.30

SubscribeBlockHeadersFromLatest handles subscription requests for block headers started from latest sealed block. It takes a SubscribeBlockHeadersFromLatestRequest and an AccessAPI_SubscribeBlockHeadersFromLatestServer stream as input. The handler manages the subscription to block updates and sends the subscribed block header information to the client via the provided stream.

Expected errors during normal operation: - codes.InvalidArgument - if unknown block status provided. - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block header to message or could not send response.

func (*Handler) SubscribeBlockHeadersFromStartBlockID added in v0.33.30

SubscribeBlockHeadersFromStartBlockID handles subscription requests for block headers started from block id. It takes a SubscribeBlockHeadersFromStartBlockIDRequest and an AccessAPI_SubscribeBlockHeadersFromStartBlockIDServer stream as input. The handler manages the subscription to block updates and sends the subscribed block header information to the client via the provided stream.

Expected errors during normal operation: - codes.InvalidArgument - if invalid startBlockID provided or unknown block status provided. - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block header to message or could not send response.

func (*Handler) SubscribeBlockHeadersFromStartHeight added in v0.33.30

SubscribeBlockHeadersFromStartHeight handles subscription requests for block headers started from block height. It takes a SubscribeBlockHeadersFromStartHeightRequest and an AccessAPI_SubscribeBlockHeadersFromStartHeightServer stream as input. The handler manages the subscription to block updates and sends the subscribed block header information to the client via the provided stream.

Expected errors during normal operation: - codes.InvalidArgument - if unknown block status provided. - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block header to message or could not send response.

func (*Handler) SubscribeBlocksFromLatest added in v0.33.30

SubscribeBlocksFromLatest handles subscription requests for blocks started from latest sealed block. It takes a SubscribeBlocksFromLatestRequest and an AccessAPI_SubscribeBlocksFromLatestServer stream as input. The handler manages the subscription to block updates and sends the subscribed block information to the client via the provided stream.

Expected errors during normal operation: - codes.InvalidArgument - if unknown block status provided. - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block to message or could not send response.

func (*Handler) SubscribeBlocksFromStartBlockID added in v0.33.30

SubscribeBlocksFromStartBlockID handles subscription requests for blocks started from block id. It takes a SubscribeBlocksFromStartBlockIDRequest and an AccessAPI_SubscribeBlocksFromStartBlockIDServer stream as input. The handler manages the subscription to block updates and sends the subscribed block information to the client via the provided stream.

Expected errors during normal operation: - codes.InvalidArgument - if invalid startBlockID provided or unknown block status provided. - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block to message or could not send response.

func (*Handler) SubscribeBlocksFromStartHeight added in v0.33.30

SubscribeBlocksFromStartHeight handles subscription requests for blocks started from block height. It takes a SubscribeBlocksFromStartHeightRequest and an AccessAPI_SubscribeBlocksFromStartHeightServer stream as input. The handler manages the subscription to block updates and sends the subscribed block information to the client via the provided stream.

Expected errors during normal operation: - codes.InvalidArgument - if unknown block status provided. - codes.ResourceExhausted - if the maximum number of streams is reached. - codes.Internal - if stream encountered an error, if stream got unexpected response or could not convert block to message or could not send response.

type HandlerOption added in v0.26.17

type HandlerOption func(*Handler)

HandlerOption is used to hand over optional constructor parameters

type IncompleteTransactionError

type IncompleteTransactionError struct {
	MissingFields []string
}

IncompleteTransactionError indicates that a transaction is missing one or more required fields.

func (IncompleteTransactionError) Error

type InsufficientBalanceError added in v0.36.2

type InsufficientBalanceError struct {
	Payer           flow.Address
	RequiredBalance cadence.UFix64
}

func (InsufficientBalanceError) Error added in v0.36.2

func (e InsufficientBalanceError) Error() string

type InvalidAddressError added in v0.11.0

type InvalidAddressError struct {
	Address flow.Address
}

InvalidAddressError indicates that a transaction references an invalid flow Address in either the Authorizers or Payer field.

func (InvalidAddressError) Error added in v0.11.0

func (e InvalidAddressError) Error() string

type InvalidGasLimitError

type InvalidGasLimitError struct {
	Maximum uint64
	Actual  uint64
}

InvalidGasLimitError indicates that a transaction specifies a gas limit that exceeds the maximum.

func (InvalidGasLimitError) Error

func (e InvalidGasLimitError) Error() string

type InvalidScriptError

type InvalidScriptError struct {
	ParserErr error
}

InvalidScriptError indicates that a transaction contains an invalid Cadence script.

func (InvalidScriptError) Error

func (e InvalidScriptError) Error() string

func (InvalidScriptError) Unwrap

func (e InvalidScriptError) Unwrap() error

type InvalidSignatureError added in v0.12.0

type InvalidSignatureError struct {
	Signature flow.TransactionSignature
}

InvalidSignatureError indicates that a transaction contains a signature with a wrong format.

func (InvalidSignatureError) Error added in v0.12.0

func (e InvalidSignatureError) Error() string

type InvalidTxByteSizeError added in v0.11.0

type InvalidTxByteSizeError struct {
	Maximum uint64
	Actual  uint64
}

InvalidTxByteSizeError indicates that a transaction byte size exceeds the maximum.

func (InvalidTxByteSizeError) Error added in v0.11.0

func (e InvalidTxByteSizeError) Error() string

type InvalidTxRateLimitedError added in v0.33.30

type InvalidTxRateLimitedError struct {
	Payer flow.Address
}

func (InvalidTxRateLimitedError) Error added in v0.33.30

type NetworkParameters

type NetworkParameters struct {
	ChainID flow.ChainID
}

NetworkParameters contains the network-wide parameters for the Flow blockchain.

type NodeVersionInfo added in v0.31.0

type NodeVersionInfo struct {
	Semver               string
	Commit               string
	SporkId              flow.Identifier
	ProtocolVersion      uint64
	SporkRootBlockHeight uint64
	NodeRootBlockHeight  uint64
}

NodeVersionInfo contains information about node, such as semver, commit, sporkID, protocolVersion, etc

type NoopLimiter added in v0.33.30

type NoopLimiter struct{}

func NewNoopLimiter added in v0.33.30

func NewNoopLimiter() *NoopLimiter

func (*NoopLimiter) IsRateLimited added in v0.33.30

func (l *NoopLimiter) IsRateLimited(address flow.Address) bool

type ProtocolStateBlocks

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

func NewProtocolStateBlocks

func NewProtocolStateBlocks(state protocol.State) *ProtocolStateBlocks

func (*ProtocolStateBlocks) FinalizedHeader

func (b *ProtocolStateBlocks) FinalizedHeader() (*flow.Header, error)

func (*ProtocolStateBlocks) HeaderByID

func (b *ProtocolStateBlocks) HeaderByID(id flow.Identifier) (*flow.Header, error)

func (*ProtocolStateBlocks) SealedHeader added in v0.36.2

func (b *ProtocolStateBlocks) SealedHeader() (*flow.Header, error)

type RateLimiter added in v0.33.30

type RateLimiter interface {
	// IsRateLimited returns true if the address is rate limited
	IsRateLimited(address flow.Address) bool
}

RateLimiter is an interface for checking if an address is rate limited. By convention, the address used is the payer field of a transaction. This rate limiter is applied when a transaction is first received by a node, meaning that if a transaction is rate-limited it will be dropped.

type TransactionResult

type TransactionResult struct {
	Status        flow.TransactionStatus
	StatusCode    uint
	Events        []flow.Event
	ErrorMessage  string
	BlockID       flow.Identifier
	TransactionID flow.Identifier
	CollectionID  flow.Identifier
	BlockHeight   uint64
}

TODO: Combine this with flow.TransactionResult?

func MessageToTransactionResult added in v0.12.5

func MessageToTransactionResult(message *access.TransactionResultResponse) *TransactionResult

type TransactionValidationOptions

type TransactionValidationOptions struct {
	Expiry                       uint
	ExpiryBuffer                 uint
	AllowEmptyReferenceBlockID   bool
	AllowUnknownReferenceBlockID bool
	MaxGasLimit                  uint64
	CheckScriptsParse            bool
	MaxTransactionByteSize       uint64
	MaxCollectionByteSize        uint64
	CheckPayerBalance            bool
}

type TransactionValidator

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

func NewTransactionValidator

func NewTransactionValidator(
	blocks Blocks,
	chain flow.Chain,
	options TransactionValidationOptions,
	executor execution.ScriptExecutor,
) (*TransactionValidator, error)

func NewTransactionValidatorWithLimiter added in v0.33.30

func NewTransactionValidatorWithLimiter(
	blocks Blocks,
	chain flow.Chain,
	options TransactionValidationOptions,
	rateLimiter RateLimiter,
) *TransactionValidator

func (*TransactionValidator) Validate

func (v *TransactionValidator) Validate(ctx context.Context, tx *flow.TransactionBody) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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