borealisproto

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Unlicense Imports: 11 Imported by: 0

README

Usage example

Decoding exact message type

import borealisproto "github.com/aurora-is-near/borealis-prototypes/go"
import "github.com/aurora-is-near/borealis-prototypes/go/payloads/rpc"

func decodeRpcRequest(data []byte) (*rpc.RpcMessage, error) {
	msg := borealisproto.Message{}
	if err := msg.UnmarshalVT(data); err != nil {
		return nil, err
	}
	rpcRequestPayload, ok := msg.Payload.(*borealisproto.Message_RpcRequest)
	if !ok {
		return nil, fmt.Errorf("not rpc request")
	}
	return rpcRequestPayload.RpcRequest, nil
}

Decoding message of yet unknown type

func decodeGeneric(data []byte) (any, error) {
	msg := borealisproto.Message{}
	if err := msg.UnmarshalVT(data); err != nil {
		return nil, err
	}
	switch t := msg.Payload.(type) {
	case *borealisproto.Message_RpcRequest:
		return t.RpcRequest, nil
	case *borealisproto.Message_RpcResponse:
		return t.RpcResponse, nil
	default:
		return nil, nil
	}
}

Encoding message

func encodeRpcResponse(rpcResponse *rpc.RpcMessage) ([]byte, error) {
	msg := &borealisproto.Message{
		Payload: &borealisproto.Message_RpcResponse{
			RpcResponse: rpcResponse,
		},
	}
	return msg.MarshalVT()
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLength        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflow          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group")
)
View Source
var File_message_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Message

type Message struct {

	// Types that are assignable to Payload:
	//
	//	*Message_Generic
	//	*Message_RpcRequest
	//	*Message_RpcResponse
	//	*Message_GetAccountStatusRequest
	//	*Message_GetAccountStatusResponse
	//	*Message_NearBlockHeader
	//	*Message_NearBlockShard
	Payload isMessage_Payload `protobuf_oneof:"payload"`
	// contains filtered or unexported fields
}

func (*Message) CloneMessageVT

func (m *Message) CloneMessageVT() proto.Message

func (*Message) CloneVT

func (m *Message) CloneVT() *Message

func (*Message) Descriptor deprecated

func (*Message) Descriptor() ([]byte, []int)

Deprecated: Use Message.ProtoReflect.Descriptor instead.

func (*Message) EqualMessageVT

func (this *Message) EqualMessageVT(thatMsg proto.Message) bool

func (*Message) EqualVT

func (this *Message) EqualVT(that *Message) bool

func (*Message) GetGeneric

func (x *Message) GetGeneric() []byte

func (*Message) GetGetAccountStatusRequest

func (x *Message) GetGetAccountStatusRequest() *get_account_status.GetAccountStatusRequest

func (*Message) GetGetAccountStatusResponse

func (x *Message) GetGetAccountStatusResponse() *get_account_status.GetAccountStatusResponse

func (*Message) GetNearBlockHeader

func (x *Message) GetNearBlockHeader() *near_block.BlockHeaderView

func (*Message) GetNearBlockShard

func (x *Message) GetNearBlockShard() *near_block.BlockShard

func (*Message) GetPayload

func (m *Message) GetPayload() isMessage_Payload

func (*Message) GetRpcRequest

func (x *Message) GetRpcRequest() *rpc.RpcMessage

func (*Message) GetRpcResponse

func (x *Message) GetRpcResponse() *rpc.RpcMessage

func (*Message) MarshalToSizedBufferVT

func (m *Message) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Message) MarshalToSizedBufferVTStrict

func (m *Message) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error)

func (*Message) MarshalToVT

func (m *Message) MarshalToVT(dAtA []byte) (int, error)

func (*Message) MarshalToVTStrict

func (m *Message) MarshalToVTStrict(dAtA []byte) (int, error)

func (*Message) MarshalVT

func (m *Message) MarshalVT() (dAtA []byte, err error)

func (*Message) MarshalVTStrict

func (m *Message) MarshalVTStrict() (dAtA []byte, err error)

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) ProtoReflect

func (x *Message) ProtoReflect() protoreflect.Message

func (*Message) Reset

func (x *Message) Reset()

func (*Message) SizeVT

func (m *Message) SizeVT() (n int)

func (*Message) String

func (x *Message) String() string

func (*Message) UnmarshalVT

func (m *Message) UnmarshalVT(dAtA []byte) error

type Message_Generic

type Message_Generic struct {
	Generic []byte `protobuf:"bytes,3,opt,name=generic,proto3,oneof"`
}

func (*Message_Generic) CloneVT

func (m *Message_Generic) CloneVT() isMessage_Payload

func (*Message_Generic) EqualVT

func (this *Message_Generic) EqualVT(thatIface isMessage_Payload) bool

func (*Message_Generic) MarshalToSizedBufferVT

func (m *Message_Generic) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Message_Generic) MarshalToSizedBufferVTStrict

func (m *Message_Generic) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error)

func (*Message_Generic) MarshalToVT

func (m *Message_Generic) MarshalToVT(dAtA []byte) (int, error)

func (*Message_Generic) MarshalToVTStrict

func (m *Message_Generic) MarshalToVTStrict(dAtA []byte) (int, error)

func (*Message_Generic) SizeVT

func (m *Message_Generic) SizeVT() (n int)

type Message_GetAccountStatusRequest

type Message_GetAccountStatusRequest struct {
	GetAccountStatusRequest *get_account_status.GetAccountStatusRequest `protobuf:"bytes,6,opt,name=get_account_status_request,json=getAccountStatusRequest,proto3,oneof"`
}

func (*Message_GetAccountStatusRequest) CloneVT

func (m *Message_GetAccountStatusRequest) CloneVT() isMessage_Payload

func (*Message_GetAccountStatusRequest) EqualVT

func (this *Message_GetAccountStatusRequest) EqualVT(thatIface isMessage_Payload) bool

func (*Message_GetAccountStatusRequest) MarshalToSizedBufferVT

func (m *Message_GetAccountStatusRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Message_GetAccountStatusRequest) MarshalToSizedBufferVTStrict

func (m *Message_GetAccountStatusRequest) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error)

func (*Message_GetAccountStatusRequest) MarshalToVT

func (m *Message_GetAccountStatusRequest) MarshalToVT(dAtA []byte) (int, error)

func (*Message_GetAccountStatusRequest) MarshalToVTStrict

func (m *Message_GetAccountStatusRequest) MarshalToVTStrict(dAtA []byte) (int, error)

func (*Message_GetAccountStatusRequest) SizeVT

func (m *Message_GetAccountStatusRequest) SizeVT() (n int)

type Message_GetAccountStatusResponse

type Message_GetAccountStatusResponse struct {
	GetAccountStatusResponse *get_account_status.GetAccountStatusResponse `protobuf:"bytes,7,opt,name=get_account_status_response,json=getAccountStatusResponse,proto3,oneof"`
}

func (*Message_GetAccountStatusResponse) CloneVT

func (m *Message_GetAccountStatusResponse) CloneVT() isMessage_Payload

func (*Message_GetAccountStatusResponse) EqualVT

func (this *Message_GetAccountStatusResponse) EqualVT(thatIface isMessage_Payload) bool

func (*Message_GetAccountStatusResponse) MarshalToSizedBufferVT

func (m *Message_GetAccountStatusResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Message_GetAccountStatusResponse) MarshalToSizedBufferVTStrict

func (m *Message_GetAccountStatusResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error)

func (*Message_GetAccountStatusResponse) MarshalToVT

func (m *Message_GetAccountStatusResponse) MarshalToVT(dAtA []byte) (int, error)

func (*Message_GetAccountStatusResponse) MarshalToVTStrict

func (m *Message_GetAccountStatusResponse) MarshalToVTStrict(dAtA []byte) (int, error)

func (*Message_GetAccountStatusResponse) SizeVT

func (m *Message_GetAccountStatusResponse) SizeVT() (n int)

type Message_NearBlockHeader

type Message_NearBlockHeader struct {
	NearBlockHeader *near_block.BlockHeaderView `protobuf:"bytes,8,opt,name=near_block_header,json=nearBlockHeader,proto3,oneof"`
}

func (*Message_NearBlockHeader) CloneVT

func (m *Message_NearBlockHeader) CloneVT() isMessage_Payload

func (*Message_NearBlockHeader) EqualVT

func (this *Message_NearBlockHeader) EqualVT(thatIface isMessage_Payload) bool

func (*Message_NearBlockHeader) MarshalToSizedBufferVT

func (m *Message_NearBlockHeader) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Message_NearBlockHeader) MarshalToSizedBufferVTStrict

func (m *Message_NearBlockHeader) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error)

func (*Message_NearBlockHeader) MarshalToVT

func (m *Message_NearBlockHeader) MarshalToVT(dAtA []byte) (int, error)

func (*Message_NearBlockHeader) MarshalToVTStrict

func (m *Message_NearBlockHeader) MarshalToVTStrict(dAtA []byte) (int, error)

func (*Message_NearBlockHeader) SizeVT

func (m *Message_NearBlockHeader) SizeVT() (n int)

type Message_NearBlockShard

type Message_NearBlockShard struct {
	NearBlockShard *near_block.BlockShard `protobuf:"bytes,9,opt,name=near_block_shard,json=nearBlockShard,proto3,oneof"`
}

func (*Message_NearBlockShard) CloneVT

func (m *Message_NearBlockShard) CloneVT() isMessage_Payload

func (*Message_NearBlockShard) EqualVT

func (this *Message_NearBlockShard) EqualVT(thatIface isMessage_Payload) bool

func (*Message_NearBlockShard) MarshalToSizedBufferVT

func (m *Message_NearBlockShard) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Message_NearBlockShard) MarshalToSizedBufferVTStrict

func (m *Message_NearBlockShard) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error)

func (*Message_NearBlockShard) MarshalToVT

func (m *Message_NearBlockShard) MarshalToVT(dAtA []byte) (int, error)

func (*Message_NearBlockShard) MarshalToVTStrict

func (m *Message_NearBlockShard) MarshalToVTStrict(dAtA []byte) (int, error)

func (*Message_NearBlockShard) SizeVT

func (m *Message_NearBlockShard) SizeVT() (n int)

type Message_RpcRequest

type Message_RpcRequest struct {
	RpcRequest *rpc.RpcMessage `protobuf:"bytes,4,opt,name=rpc_request,json=rpcRequest,proto3,oneof"`
}

func (*Message_RpcRequest) CloneVT

func (m *Message_RpcRequest) CloneVT() isMessage_Payload

func (*Message_RpcRequest) EqualVT

func (this *Message_RpcRequest) EqualVT(thatIface isMessage_Payload) bool

func (*Message_RpcRequest) MarshalToSizedBufferVT

func (m *Message_RpcRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Message_RpcRequest) MarshalToSizedBufferVTStrict

func (m *Message_RpcRequest) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error)

func (*Message_RpcRequest) MarshalToVT

func (m *Message_RpcRequest) MarshalToVT(dAtA []byte) (int, error)

func (*Message_RpcRequest) MarshalToVTStrict

func (m *Message_RpcRequest) MarshalToVTStrict(dAtA []byte) (int, error)

func (*Message_RpcRequest) SizeVT

func (m *Message_RpcRequest) SizeVT() (n int)

type Message_RpcResponse

type Message_RpcResponse struct {
	RpcResponse *rpc.RpcMessage `protobuf:"bytes,5,opt,name=rpc_response,json=rpcResponse,proto3,oneof"`
}

func (*Message_RpcResponse) CloneVT

func (m *Message_RpcResponse) CloneVT() isMessage_Payload

func (*Message_RpcResponse) EqualVT

func (this *Message_RpcResponse) EqualVT(thatIface isMessage_Payload) bool

func (*Message_RpcResponse) MarshalToSizedBufferVT

func (m *Message_RpcResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Message_RpcResponse) MarshalToSizedBufferVTStrict

func (m *Message_RpcResponse) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error)

func (*Message_RpcResponse) MarshalToVT

func (m *Message_RpcResponse) MarshalToVT(dAtA []byte) (int, error)

func (*Message_RpcResponse) MarshalToVTStrict

func (m *Message_RpcResponse) MarshalToVTStrict(dAtA []byte) (int, error)

func (*Message_RpcResponse) SizeVT

func (m *Message_RpcResponse) SizeVT() (n int)

Directories

Path Synopsis
payloads
rpc

Jump to

Keyboard shortcuts

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