Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrPartialInvalidPayload = sdkerrors.Register(codespace, 1, "invalid partial payload") ErrPartialUnrecognisedRequestFormat = sdkerrors.Register(codespace, 2, "unrecognised request format in partial payload") )
Functions ¶
func GetComputeUnits ¶
GetComputeUnits returns the compute units for the RPC request provided
func GetErrorReply ¶
GetErrorReply returns an error reply for the given payload and error, in the correct format required by the request type.
func GetRequestType ¶
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.