Documentation ¶
Index ¶
- Constants
- func ConvertError(err error, msg string, defaultCode codes.Code) error
- func ConvertIndexError(err error, height uint64, defaultMsg string) error
- func ConvertMultiError(err *multierror.Error, msg string, defaultCode codes.Code) error
- func ConvertStorageError(err error) error
- func IdentifierList(ids []string) (flow.IdentifierList, error)
- func InterceptorLogger(l zerolog.Logger) logging.Logger
- func LoggingInterceptor(log zerolog.Logger) []grpc.UnaryServerInterceptor
- func NewRateLimiterInterceptor(log zerolog.Logger, apiRateLimits map[string]int, ...) *rateLimiterInterceptor
- type ExecutionNodeIdentitiesProvider
Constants ¶
const MaxNodesCnt = 3
MaxNodesCnt is the maximum number of nodes that will be contacted to complete an API request.
Variables ¶
This section is empty.
Functions ¶
func ConvertError ¶ added in v0.30.0
ConvertError converts a generic error into a grpc status error. The input may either be a status.Error already, or standard error type. Any error that matches on of the common status code mappings will be converted, all unmatched errors will be converted to the provided defaultCode.
func ConvertIndexError ¶ added in v0.33.13
ConvertIndexError converts errors related to index and storage to appropriate gRPC status errors. If the error is nil, it returns nil. If the error is not recognized, it falls back to ConvertError with the provided default message and Internal gRPC code.
func ConvertMultiError ¶ added in v0.29.12
ConvertMultiError converts a multierror to a grpc status error. If the errors have related status codes, the common code is returned, otherwise defaultCode is used.
func ConvertStorageError ¶ added in v0.29.0
ConvertStorageError converts a generic error into a grpc status error, converting storage errors into codes.NotFound
func IdentifierList ¶
func IdentifierList(ids []string) (flow.IdentifierList, error)
func InterceptorLogger ¶ added in v0.33.30
InterceptorLogger adapts zerolog logger to interceptor logger. This code is simple enough to be copied and not imported.
func LoggingInterceptor ¶ added in v0.29.0
func LoggingInterceptor(log zerolog.Logger) []grpc.UnaryServerInterceptor
LoggingInterceptor creates the logging interceptors to log incoming GRPC request and response (minus the payload body)
func NewRateLimiterInterceptor ¶
func NewRateLimiterInterceptor(log zerolog.Logger, apiRateLimits map[string]int, apiBurstLimits map[string]int) *rateLimiterInterceptor
NewRateLimiterInterceptor creates a new rate limiter interceptor with the defined per second rate limits and the optional burst limit for each API.
Types ¶
type ExecutionNodeIdentitiesProvider ¶
type ExecutionNodeIdentitiesProvider struct {
// contains filtered or unexported fields
}
ExecutionNodeIdentitiesProvider is a container for elements required to retrieve execution node identities for a given block ID.
func NewExecutionNodeIdentitiesProvider ¶
func NewExecutionNodeIdentitiesProvider( log zerolog.Logger, state protocol.State, executionReceipts storage.ExecutionReceipts, preferredENIdentifiers flow.IdentifierList, fixedENIdentifiers flow.IdentifierList, ) *ExecutionNodeIdentitiesProvider
NewExecutionNodeIdentitiesProvider creates and returns a new instance of ExecutionNodeIdentitiesProvider.
Parameters:
- log: The logger to use for logging.
- state: The protocol state used for retrieving block information.
- executionReceipts: A storage.ExecutionReceipts object that contains the execution receipts for blocks.
- preferredENIdentifiers: A flow.IdentifierList of preferred execution node identifiers that are prioritized during selection.
- fixedENIdentifiers: A flow.IdentifierList of fixed execution node identifiers that are always considered if available.
func (*ExecutionNodeIdentitiesProvider) ChooseFromPreferredENIDs ¶
func (e *ExecutionNodeIdentitiesProvider) ChooseFromPreferredENIDs( allENs flow.IdentityList, executorIDs flow.IdentifierList, ) flow.IdentityList
ChooseFromPreferredENIDs finds the subset of execution nodes if preferred execution nodes are defined. If preferredENIdentifiers is set and there are less than maxNodesCnt nodes selected, than the list is padded up to maxNodesCnt nodes using the following order: 1. Use any EN with a receipt. 2. Use any preferred node not already selected. 3. Use any EN not already selected.
func (*ExecutionNodeIdentitiesProvider) ExecutionNodesForBlockID ¶
func (e *ExecutionNodeIdentitiesProvider) ExecutionNodesForBlockID( ctx context.Context, blockID flow.Identifier, ) (flow.IdentitySkeletonList, error)
ExecutionNodesForBlockID returns upto maxNodesCnt number of randomly chosen execution node identities which have executed the given block ID. If no such execution node is found, an InsufficientExecutionReceipts error is returned.