partials

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPartialInvalidPayload            = sdkerrors.Register(codespace, 1, "invalid partial payload")
	ErrPartialUnrecognisedRequestFormat = sdkerrors.Register(codespace, 2, "unrecognised request format in partial payload")
)

Functions

func GetComputeUnits

func GetComputeUnits(ctx context.Context, payloadBz []byte) (uint64, error)

GetComputeUnits returns the compute units for the RPC request provided

func GetErrorReply

func GetErrorReply(ctx context.Context, payloadBz []byte, err error) ([]byte, error)

GetErrorReply returns an error reply for the given payload and error, in the correct format required by the request type.

func GetRequestType

func GetRequestType(ctx context.Context, payloadBz []byte) (sharedtypes.RPCType, error)

GetRequestType returns the request type for the given payload.

Types

type PartialPayload

type PartialPayload interface {
	// GetRPCType returns the request type for the given payload.
	GetRPCType() sharedtypes.RPCType
	// GenerateErrorPayload creates an error message from the provided error
	// compatible with the protocol of this RPC type.
	GenerateErrorPayload(err error) ([]byte, error)
	// GetRPCComputeUnits returns the compute units for the RPC request
	GetRPCComputeUnits(ctx context.Context) (uint64, error)
	// ValidateBasic ensures that all the required fields are set in the partial
	// payload.
	ValidateBasic(ctx context.Context) error
}

PartialPayload defines an interface for partial RPC payloads that enables the transparent relaying of RPC requests from applications to suppliers. In order for this to occur we must be able to infer its format. This requires the RPC payload to be partially decoded, extracting the required fields, currently limited for the purpose of determine the RPC type, compute units and error generation, but may be used for other logic in the future

func PartiallyUnmarshalRequest

func PartiallyUnmarshalRequest(ctx context.Context, payloadBz []byte) (PartialPayload, error)

TODO_BLOCKER(@h5law): This function currently only supports JSON-RPC and must be extended to other request types. PartiallyUnmarshalRequest unmarshals the payload into a partial request that contains only the fields necessary to generate an error response and handle accounting for the request's method.

Directories

Path Synopsis
Package payloads contains the different types of RPC payloads the partials package supports.
Package payloads contains the different types of RPC payloads the partials package supports.

Jump to

Keyboard shortcuts

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