diff --git a/go.mod b/go.mod index cf59b00c0e..e7edd3cdcd 100644 --- a/go.mod +++ b/go.mod @@ -44,7 +44,6 @@ require ( github.com/multiformats/go-multihash v0.2.3 github.com/pelletier/go-toml v1.9.5 github.com/pkg/errors v0.9.1 - github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 github.com/sourcenetwork/acp_core v0.0.0-20240607160510-47a5306b2ad2 github.com/sourcenetwork/badger/v4 v4.2.1-0.20231113215945-a63444ca5276 github.com/sourcenetwork/corelog v0.0.8 @@ -66,7 +65,6 @@ require ( golang.org/x/crypto v0.27.0 golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa google.golang.org/grpc v1.67.0 - google.golang.org/protobuf v1.34.2 ) require ( @@ -375,6 +373,7 @@ require ( google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 43308a4372..ed7cf49e3d 100644 --- a/go.sum +++ b/go.sum @@ -1265,8 +1265,6 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= -github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= -github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/internal/kms/pubsub.go b/internal/kms/pubsub.go index ca67603a7c..cbcd6ee141 100644 --- a/internal/kms/pubsub.go +++ b/internal/kms/pubsub.go @@ -16,18 +16,17 @@ import ( "crypto/ecdh" "encoding/base64" + "github.com/fxamacker/cbor/v2" cidlink "github.com/ipld/go-ipld-prime/linking/cid" libpeer "github.com/libp2p/go-libp2p/core/peer" rpc "github.com/sourcenetwork/go-libp2p-pubsub-rpc" grpcpeer "google.golang.org/grpc/peer" - "google.golang.org/protobuf/proto" "github.com/sourcenetwork/defradb/crypto" "github.com/sourcenetwork/defradb/datastore" "github.com/sourcenetwork/defradb/errors" "github.com/sourcenetwork/defradb/event" "github.com/sourcenetwork/defradb/internal/encryption" - pb "github.com/sourcenetwork/defradb/net/pb" ) const pubsubTopic = "encryption" @@ -127,10 +126,15 @@ func (s *pubSubService) handleKeyRequestedEvent() { } } +type fetchEncryptionKeyRequest struct { + Links [][]byte + EphemeralPublicKey []byte +} + // handleEncryptionMessage handles incoming FetchEncryptionKeyRequest messages from the pubsub network. func (s *pubSubService) handleRequestFromPeer(peerID libpeer.ID, topic string, msg []byte) ([]byte, error) { - req := new(pb.FetchEncryptionKeyRequest) - if err := proto.Unmarshal(msg, req); err != nil { + req := new(fetchEncryptionKeyRequest) + if err := cbor.Unmarshal(msg, req); err != nil { log.ErrorContextE(s.ctx, "Failed to unmarshal pubsub message %s", err) return nil, err } @@ -141,14 +145,14 @@ func (s *pubSubService) handleRequestFromPeer(peerID libpeer.ID, topic string, m log.ErrorContextE(s.ctx, "failed attempt to get encryption key", err) return nil, errors.Wrap("failed attempt to get encryption key", err) } - return res.MarshalVT() + return cbor.Marshal(res) } func (s *pubSubService) prepareFetchEncryptionKeyRequest( cids []cidlink.Link, ephemeralPublicKey []byte, -) (*pb.FetchEncryptionKeyRequest, error) { - req := &pb.FetchEncryptionKeyRequest{ +) (*fetchEncryptionKeyRequest, error) { + req := &fetchEncryptionKeyRequest{ EphemeralPublicKey: ephemeralPublicKey, } @@ -177,7 +181,7 @@ func (s *pubSubService) requestEncryptionKeyFromPeers( return err } - data, err := req.MarshalVT() + data, err := cbor.Marshal(req) if err != nil { return errors.Wrap("failed to marshal pubsub message", err) } @@ -194,17 +198,23 @@ func (s *pubSubService) requestEncryptionKeyFromPeers( return nil } +type fetchEncryptionKeyReply struct { + Links [][]byte + Blocks [][]byte + EphemeralPublicKey []byte +} + // handleFetchEncryptionKeyResponse handles incoming FetchEncryptionKeyResponse messages func (s *pubSubService) handleFetchEncryptionKeyResponse( resp rpc.Response, - req *pb.FetchEncryptionKeyRequest, + req *fetchEncryptionKeyRequest, privateKey *ecdh.PrivateKey, result chan<- encryption.Result, ) { defer close(result) - var keyResp pb.FetchEncryptionKeyReply - if err := proto.Unmarshal(resp.Data, &keyResp); err != nil { + var keyResp fetchEncryptionKeyReply + if err := cbor.Unmarshal(resp.Data, &keyResp); err != nil { log.ErrorContextE(s.ctx, "Failed to unmarshal encryption key response", err) result <- encryption.Result{Error: err} return @@ -238,7 +248,7 @@ func (s *pubSubService) handleFetchEncryptionKeyResponse( } // makeAssociatedData creates the associated data for the encryption key request -func makeAssociatedData(req *pb.FetchEncryptionKeyRequest, peerID libpeer.ID) []byte { +func makeAssociatedData(req *fetchEncryptionKeyRequest, peerID libpeer.ID) []byte { return encodeToBase64(bytes.Join([][]byte{ req.EphemeralPublicKey, []byte(peerID), @@ -247,8 +257,8 @@ func makeAssociatedData(req *pb.FetchEncryptionKeyRequest, peerID libpeer.ID) [] func (s *pubSubService) tryGenEncryptionKeyLocally( ctx context.Context, - req *pb.FetchEncryptionKeyRequest, -) (*pb.FetchEncryptionKeyReply, error) { + req *fetchEncryptionKeyRequest, +) (*fetchEncryptionKeyReply, error) { blocks, err := s.getEncryptionKeysLocally(ctx, req) if err != nil || len(blocks) == 0 { return nil, err @@ -264,7 +274,7 @@ func (s *pubSubService) tryGenEncryptionKeyLocally( return nil, err } - res := &pb.FetchEncryptionKeyReply{ + res := &fetchEncryptionKeyReply{ Links: req.Links, EphemeralPublicKey: privKey.PublicKey().Bytes(), } @@ -293,7 +303,7 @@ func (s *pubSubService) tryGenEncryptionKeyLocally( // It returns the encryption keys and the targets for which the keys were found. func (s *pubSubService) getEncryptionKeysLocally( ctx context.Context, - req *pb.FetchEncryptionKeyRequest, + req *fetchEncryptionKeyRequest, ) ([][]byte, error) { blocks := make([][]byte, 0, len(req.Links)) for _, link := range req.Links { diff --git a/net/client.go b/net/client.go index 9d11a968d4..35c1de139d 100644 --- a/net/client.go +++ b/net/client.go @@ -20,7 +20,6 @@ import ( "github.com/sourcenetwork/defradb/errors" "github.com/sourcenetwork/defradb/event" - pb "github.com/sourcenetwork/defradb/net/pb" ) var ( @@ -32,19 +31,6 @@ var ( // pushLog creates a pushLog request and sends it to another node // over libp2p grpc connection func (s *server) pushLog(evt event.Update, pid peer.ID) error { - body := &pb.PushLogRequest_Body{ - DocID: []byte(evt.DocID), - Cid: evt.Cid.Bytes(), - SchemaRoot: []byte(evt.SchemaRoot), - Creator: s.peer.host.ID().String(), - Log: &pb.Log{ - Block: evt.Block, - }, - } - req := &pb.PushLogRequest{ - Body: body, - } - client, err := s.dial(pid) // grpc dial over P2P stream if err != nil { return NewErrPushLog(err) @@ -53,7 +39,14 @@ func (s *server) pushLog(evt event.Update, pid peer.ID) error { ctx, cancel := context.WithTimeout(s.peer.ctx, PushTimeout) defer cancel() - if _, err := client.PushLog(ctx, req); err != nil { + req := pushLogRequest{ + DocID: evt.DocID, + CID: evt.Cid.Bytes(), + SchemaRoot: evt.SchemaRoot, + Creator: s.peer.host.ID().String(), + Block: evt.Block, + } + if err := client.Invoke(ctx, servicePushLogName, req, nil); err != nil { return NewErrPushLog( err, errors.NewKV("CID", evt.Cid), diff --git a/net/codec.go b/net/codec.go new file mode 100644 index 0000000000..258e66b091 --- /dev/null +++ b/net/codec.go @@ -0,0 +1,40 @@ +// Copyright 2024 Democratized Data Foundation +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package net + +import ( + "github.com/fxamacker/cbor/v2" + "google.golang.org/grpc/encoding" +) + +const cborCodecName = "cbor" + +// cborCodec is a gRPC Codec implementation with CBOR encoding. +type cborCodec struct{} + +func (c *cborCodec) Marshal(v any) ([]byte, error) { + return cbor.Marshal(v) +} + +func (c *cborCodec) Unmarshal(data []byte, v any) error { + if v == nil { + return nil + } + return cbor.Unmarshal(data, v) +} + +func (c *cborCodec) Name() string { + return cborCodecName +} + +func init() { + encoding.RegisterCodec(&cborCodec{}) +} diff --git a/net/dialer.go b/net/dialer.go index 0202da8d9d..08a22ffc5e 100644 --- a/net/dialer.go +++ b/net/dialer.go @@ -23,11 +23,10 @@ import ( "github.com/sourcenetwork/defradb/errors" corenet "github.com/sourcenetwork/defradb/internal/core/net" - pb "github.com/sourcenetwork/defradb/net/pb" ) // dial attempts to open a gRPC connection over libp2p to a peer. -func (s *server) dial(peerID libpeer.ID) (pb.ServiceClient, error) { +func (s *server) dial(peerID libpeer.ID) (*grpc.ClientConn, error) { s.mu.Lock() defer s.mu.Unlock() conn, ok := s.conns[peerID] @@ -37,7 +36,7 @@ func (s *server) dial(peerID libpeer.ID) (pb.ServiceClient, error) { return nil, err } } else { - return pb.NewServiceClient(conn), nil + return conn, nil } } // We need the "passthrough:" in the beginning of the target, @@ -54,7 +53,7 @@ func (s *server) dial(peerID libpeer.ID) (pb.ServiceClient, error) { return nil, err } s.conns[peerID] = conn - return pb.NewServiceClient(conn), nil + return conn, nil } // getLibp2pDialer returns a WithContextDialer option for libp2p dialing. diff --git a/net/grpc.go b/net/grpc.go new file mode 100644 index 0000000000..8e526de102 --- /dev/null +++ b/net/grpc.go @@ -0,0 +1,105 @@ +// Copyright 2024 Democratized Data Foundation +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package net + +import ( + "context" + + "google.golang.org/grpc" +) + +const ( + grpcServiceName = "defradb.net.Service" + + serviceGetDocGraphName = "/" + grpcServiceName + "/GetDocGraph" + servicePushDocGraphName = "/" + grpcServiceName + "/PushDocGraph" + serviceGetLogName = "/" + grpcServiceName + "/GetLog" + servicePushLogName = "/" + grpcServiceName + "/PushLog" + serviceGetHeadLogName = "/" + grpcServiceName + "/GetHeadLog" +) + +type getDocGraphRequest struct{} + +type getDocGraphReply struct{} + +type getHeadLogRequest struct{} + +type getHeadLogReply struct{} + +type getLogRequest struct{} + +type getLogReply struct{} + +type pushDocGraphRequest struct{} + +type pushDocGraphReply struct{} + +type pushLogRequest struct { + DocID string + CID []byte + SchemaRoot string + Creator string + Block []byte +} + +type pushLogReply struct{} + +type serviceServer interface { + // GetDocGraph from this peer. + GetDocGraph(context.Context, *getDocGraphRequest) (*getDocGraphReply, error) + // PushDocGraph to this peer. + PushDocGraph(context.Context, *pushDocGraphRequest) (*pushDocGraphReply, error) + // GetLog from this peer. + GetLog(context.Context, *getLogRequest) (*getLogReply, error) + // PushLog to this peer. + PushLog(context.Context, *pushLogRequest) (*pushLogReply, error) + // GetHeadLog from this peer + GetHeadLog(context.Context, *getHeadLogRequest) (*getHeadLogReply, error) +} + +func pushLogHandler( + srv any, + ctx context.Context, + dec func(any) error, + interceptor grpc.UnaryServerInterceptor, +) (any, error) { + in := new(pushLogRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(serviceServer).PushLog(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: servicePushLogName, + } + handler := func(ctx context.Context, req any) (any, error) { + return srv.(serviceServer).PushLog(ctx, req.(*pushLogRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func registerServiceServer(s grpc.ServiceRegistrar, srv serviceServer) { + desc := &grpc.ServiceDesc{ + ServiceName: grpcServiceName, + HandlerType: (*serviceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "PushLog", + Handler: pushLogHandler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "defradb.cbor", + } + s.RegisterService(desc, srv) +} diff --git a/net/pb/Makefile b/net/pb/Makefile deleted file mode 100644 index 30b0e92dfa..0000000000 --- a/net/pb/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -PB = $(wildcard *.proto) -GO = $(PB:.proto=.pb.go) - -PROTOC_GEN_GO := $(shell which protoc-gen-go) -PROTOC_GEN_GO_GRPC := $(shell which protoc-gen-go-grpc) -PROTOC_GEN_GO_VTPROTO := $(shell which protoc-gen-go-vtproto) - -all: $(GO) - -.PHONY: deps -deps: - go install google.golang.org/protobuf/cmd/protoc-gen-go@latest - go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest - go install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto@latest - -%.pb.go: %.proto - protoc \ - -I. \ - --go_out=. --plugin protoc-gen-go="$(PROTOC_GEN_GO)" \ - --go-grpc_out=. --plugin protoc-gen-go-grpc="$(PROTOC_GEN_GO_GRPC)" \ - --go-vtproto_out=. --plugin protoc-gen-go-vtproto="$(PROTOC_GEN_GO_VTPROTO)" \ - --go-vtproto_opt=features=marshal+unmarshal+size \ - $< # This line specifies the input file - -.PHONY: clean -clean: - rm -f *.pb.go - rm -f *pb_test.go diff --git a/net/pb/net.pb.go b/net/pb/net.pb.go deleted file mode 100644 index dbac6829d0..0000000000 --- a/net/pb/net.pb.go +++ /dev/null @@ -1,983 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.1 -// source: net.proto - -package net_pb - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// Log represents a thread log. -type Log struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // block is the top-level node's raw data as an ipld.Block. - Block []byte `protobuf:"bytes,1,opt,name=block,proto3" json:"block,omitempty"` -} - -func (x *Log) Reset() { - *x = Log{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Log) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Log) ProtoMessage() {} - -func (x *Log) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Log.ProtoReflect.Descriptor instead. -func (*Log) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{0} -} - -func (x *Log) GetBlock() []byte { - if x != nil { - return x.Block - } - return nil -} - -type GetDocGraphRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *GetDocGraphRequest) Reset() { - *x = GetDocGraphRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetDocGraphRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetDocGraphRequest) ProtoMessage() {} - -func (x *GetDocGraphRequest) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetDocGraphRequest.ProtoReflect.Descriptor instead. -func (*GetDocGraphRequest) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{1} -} - -type GetDocGraphReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *GetDocGraphReply) Reset() { - *x = GetDocGraphReply{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetDocGraphReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetDocGraphReply) ProtoMessage() {} - -func (x *GetDocGraphReply) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetDocGraphReply.ProtoReflect.Descriptor instead. -func (*GetDocGraphReply) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{2} -} - -type PushDocGraphRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *PushDocGraphRequest) Reset() { - *x = PushDocGraphRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PushDocGraphRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PushDocGraphRequest) ProtoMessage() {} - -func (x *PushDocGraphRequest) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PushDocGraphRequest.ProtoReflect.Descriptor instead. -func (*PushDocGraphRequest) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{3} -} - -type PushDocGraphReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *PushDocGraphReply) Reset() { - *x = PushDocGraphReply{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PushDocGraphReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PushDocGraphReply) ProtoMessage() {} - -func (x *PushDocGraphReply) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PushDocGraphReply.ProtoReflect.Descriptor instead. -func (*PushDocGraphReply) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{4} -} - -type GetLogRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *GetLogRequest) Reset() { - *x = GetLogRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetLogRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetLogRequest) ProtoMessage() {} - -func (x *GetLogRequest) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetLogRequest.ProtoReflect.Descriptor instead. -func (*GetLogRequest) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{5} -} - -type GetLogReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *GetLogReply) Reset() { - *x = GetLogReply{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetLogReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetLogReply) ProtoMessage() {} - -func (x *GetLogReply) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetLogReply.ProtoReflect.Descriptor instead. -func (*GetLogReply) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{6} -} - -type PushLogRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Body *PushLogRequest_Body `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"` -} - -func (x *PushLogRequest) Reset() { - *x = PushLogRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PushLogRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PushLogRequest) ProtoMessage() {} - -func (x *PushLogRequest) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PushLogRequest.ProtoReflect.Descriptor instead. -func (*PushLogRequest) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{7} -} - -func (x *PushLogRequest) GetBody() *PushLogRequest_Body { - if x != nil { - return x.Body - } - return nil -} - -// FetchEncryptionKeyRequest is a request to receive a doc encryption key -// from a peer that holds it. -type FetchEncryptionKeyRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // links is the list of cid links of the blocks containing encryption keys. - Links [][]byte `protobuf:"bytes,1,rep,name=links,proto3" json:"links,omitempty"` - // ephemeralPublicKey is an ephemeral public of the requesting peer for deriving shared secret - EphemeralPublicKey []byte `protobuf:"bytes,2,opt,name=ephemeralPublicKey,proto3" json:"ephemeralPublicKey,omitempty"` -} - -func (x *FetchEncryptionKeyRequest) Reset() { - *x = FetchEncryptionKeyRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *FetchEncryptionKeyRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*FetchEncryptionKeyRequest) ProtoMessage() {} - -func (x *FetchEncryptionKeyRequest) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use FetchEncryptionKeyRequest.ProtoReflect.Descriptor instead. -func (*FetchEncryptionKeyRequest) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{8} -} - -func (x *FetchEncryptionKeyRequest) GetLinks() [][]byte { - if x != nil { - return x.Links - } - return nil -} - -func (x *FetchEncryptionKeyRequest) GetEphemeralPublicKey() []byte { - if x != nil { - return x.EphemeralPublicKey - } - return nil -} - -// FetchEncryptionKeyReply is a response to FetchEncryptionKeyRequest request -// by a peer that holds the requested doc encryption key. -type FetchEncryptionKeyReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // links is the list of cid links of the blocks containing encryption keys. - Links [][]byte `protobuf:"bytes,1,rep,name=links,proto3" json:"links,omitempty"` - // blocks is the list of blocks containing encryption keys. The order of blocks should match the order of links. - // Every block is encrypted and contains a nonce. - Blocks [][]byte `protobuf:"bytes,2,rep,name=blocks,proto3" json:"blocks,omitempty"` - // ephemeralPublicKey is an ephemeral public of the responding peer for deriving shared secret - EphemeralPublicKey []byte `protobuf:"bytes,3,opt,name=ephemeralPublicKey,proto3" json:"ephemeralPublicKey,omitempty"` -} - -func (x *FetchEncryptionKeyReply) Reset() { - *x = FetchEncryptionKeyReply{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *FetchEncryptionKeyReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*FetchEncryptionKeyReply) ProtoMessage() {} - -func (x *FetchEncryptionKeyReply) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use FetchEncryptionKeyReply.ProtoReflect.Descriptor instead. -func (*FetchEncryptionKeyReply) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{9} -} - -func (x *FetchEncryptionKeyReply) GetLinks() [][]byte { - if x != nil { - return x.Links - } - return nil -} - -func (x *FetchEncryptionKeyReply) GetBlocks() [][]byte { - if x != nil { - return x.Blocks - } - return nil -} - -func (x *FetchEncryptionKeyReply) GetEphemeralPublicKey() []byte { - if x != nil { - return x.EphemeralPublicKey - } - return nil -} - -type GetHeadLogRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *GetHeadLogRequest) Reset() { - *x = GetHeadLogRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetHeadLogRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetHeadLogRequest) ProtoMessage() {} - -func (x *GetHeadLogRequest) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetHeadLogRequest.ProtoReflect.Descriptor instead. -func (*GetHeadLogRequest) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{10} -} - -type PushLogReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *PushLogReply) Reset() { - *x = PushLogReply{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PushLogReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PushLogReply) ProtoMessage() {} - -func (x *PushLogReply) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PushLogReply.ProtoReflect.Descriptor instead. -func (*PushLogReply) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{11} -} - -type GetHeadLogReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *GetHeadLogReply) Reset() { - *x = GetHeadLogReply{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetHeadLogReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetHeadLogReply) ProtoMessage() {} - -func (x *GetHeadLogReply) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[12] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetHeadLogReply.ProtoReflect.Descriptor instead. -func (*GetHeadLogReply) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{12} -} - -type PushLogRequest_Body struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // docID is the ID of the document that is affected by the log. - DocID []byte `protobuf:"bytes,1,opt,name=docID,proto3" json:"docID,omitempty"` - // cid is the CID of the composite of the document. - Cid []byte `protobuf:"bytes,2,opt,name=cid,proto3" json:"cid,omitempty"` - // schemaRoot is the SchemaRoot of the collection that the document resides in. - SchemaRoot []byte `protobuf:"bytes,3,opt,name=schemaRoot,proto3" json:"schemaRoot,omitempty"` - // creator is the PeerID of the peer that created the log. - Creator string `protobuf:"bytes,4,opt,name=creator,proto3" json:"creator,omitempty"` - // log hold the block that represent version of the document. - Log *Log `protobuf:"bytes,6,opt,name=log,proto3" json:"log,omitempty"` -} - -func (x *PushLogRequest_Body) Reset() { - *x = PushLogRequest_Body{} - if protoimpl.UnsafeEnabled { - mi := &file_net_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PushLogRequest_Body) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PushLogRequest_Body) ProtoMessage() {} - -func (x *PushLogRequest_Body) ProtoReflect() protoreflect.Message { - mi := &file_net_proto_msgTypes[13] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PushLogRequest_Body.ProtoReflect.Descriptor instead. -func (*PushLogRequest_Body) Descriptor() ([]byte, []int) { - return file_net_proto_rawDescGZIP(), []int{7, 0} -} - -func (x *PushLogRequest_Body) GetDocID() []byte { - if x != nil { - return x.DocID - } - return nil -} - -func (x *PushLogRequest_Body) GetCid() []byte { - if x != nil { - return x.Cid - } - return nil -} - -func (x *PushLogRequest_Body) GetSchemaRoot() []byte { - if x != nil { - return x.SchemaRoot - } - return nil -} - -func (x *PushLogRequest_Body) GetCreator() string { - if x != nil { - return x.Creator - } - return "" -} - -func (x *PushLogRequest_Body) GetLog() *Log { - if x != nil { - return x.Log - } - return nil -} - -var File_net_proto protoreflect.FileDescriptor - -var file_net_proto_rawDesc = []byte{ - 0x0a, 0x09, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x6e, 0x65, 0x74, - 0x2e, 0x70, 0x62, 0x22, 0x1b, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x22, 0x14, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, 0x68, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x12, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, - 0x47, 0x72, 0x61, 0x70, 0x68, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x15, 0x0a, 0x13, 0x50, 0x75, - 0x73, 0x68, 0x44, 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x22, 0x13, 0x0a, 0x11, 0x50, 0x75, 0x73, 0x68, 0x44, 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, - 0x68, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x0f, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x67, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x0d, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x4c, 0x6f, - 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0xcb, 0x01, 0x0a, 0x0e, 0x50, 0x75, 0x73, 0x68, 0x4c, - 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2f, 0x0a, 0x04, 0x62, 0x6f, 0x64, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, - 0x2e, 0x50, 0x75, 0x73, 0x68, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, - 0x42, 0x6f, 0x64, 0x79, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x1a, 0x87, 0x01, 0x0a, 0x04, 0x42, - 0x6f, 0x64, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x6f, 0x63, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x05, 0x64, 0x6f, 0x63, 0x49, 0x44, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x63, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x73, - 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x6f, 0x6f, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x0a, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, - 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x72, - 0x65, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x1d, 0x0a, 0x03, 0x6c, 0x6f, 0x67, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x6f, 0x67, 0x52, - 0x03, 0x6c, 0x6f, 0x67, 0x22, 0x61, 0x0a, 0x19, 0x46, 0x65, 0x74, 0x63, 0x68, 0x45, 0x6e, 0x63, - 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, - 0x52, 0x05, 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x12, 0x2e, 0x0a, 0x12, 0x65, 0x70, 0x68, 0x65, 0x6d, - 0x65, 0x72, 0x61, 0x6c, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x12, 0x65, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x50, 0x75, - 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x22, 0x77, 0x0a, 0x17, 0x46, 0x65, 0x74, 0x63, 0x68, - 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x70, - 0x6c, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0c, 0x52, 0x05, 0x6c, 0x69, 0x6e, 0x6b, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x6c, 0x6f, 0x63, - 0x6b, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x06, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, - 0x12, 0x2e, 0x0a, 0x12, 0x65, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x50, 0x75, 0x62, - 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x12, 0x65, 0x70, - 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, - 0x22, 0x13, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x4c, 0x6f, 0x67, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x50, 0x75, 0x73, 0x68, 0x4c, 0x6f, 0x67, - 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x11, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, - 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x32, 0xd1, 0x02, 0x0a, 0x07, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x12, 0x45, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, 0x47, 0x72, - 0x61, 0x70, 0x68, 0x12, 0x1a, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, - 0x44, 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x18, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x63, 0x47, - 0x72, 0x61, 0x70, 0x68, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x0c, 0x50, - 0x75, 0x73, 0x68, 0x44, 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, 0x68, 0x12, 0x1b, 0x2e, 0x6e, 0x65, - 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x44, 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, - 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, - 0x62, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x44, 0x6f, 0x63, 0x47, 0x72, 0x61, 0x70, 0x68, 0x52, 0x65, - 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x36, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x67, 0x12, - 0x15, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x67, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, - 0x47, 0x65, 0x74, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x39, 0x0a, - 0x07, 0x50, 0x75, 0x73, 0x68, 0x4c, 0x6f, 0x67, 0x12, 0x16, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, - 0x62, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x14, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x50, 0x75, 0x73, 0x68, 0x4c, 0x6f, - 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x42, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x48, - 0x65, 0x61, 0x64, 0x4c, 0x6f, 0x67, 0x12, 0x19, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, - 0x47, 0x65, 0x74, 0x48, 0x65, 0x61, 0x64, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x17, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x48, 0x65, - 0x61, 0x64, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, - 0x2f, 0x3b, 0x6e, 0x65, 0x74, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_net_proto_rawDescOnce sync.Once - file_net_proto_rawDescData = file_net_proto_rawDesc -) - -func file_net_proto_rawDescGZIP() []byte { - file_net_proto_rawDescOnce.Do(func() { - file_net_proto_rawDescData = protoimpl.X.CompressGZIP(file_net_proto_rawDescData) - }) - return file_net_proto_rawDescData -} - -var file_net_proto_msgTypes = make([]protoimpl.MessageInfo, 14) -var file_net_proto_goTypes = []any{ - (*Log)(nil), // 0: net.pb.Log - (*GetDocGraphRequest)(nil), // 1: net.pb.GetDocGraphRequest - (*GetDocGraphReply)(nil), // 2: net.pb.GetDocGraphReply - (*PushDocGraphRequest)(nil), // 3: net.pb.PushDocGraphRequest - (*PushDocGraphReply)(nil), // 4: net.pb.PushDocGraphReply - (*GetLogRequest)(nil), // 5: net.pb.GetLogRequest - (*GetLogReply)(nil), // 6: net.pb.GetLogReply - (*PushLogRequest)(nil), // 7: net.pb.PushLogRequest - (*FetchEncryptionKeyRequest)(nil), // 8: net.pb.FetchEncryptionKeyRequest - (*FetchEncryptionKeyReply)(nil), // 9: net.pb.FetchEncryptionKeyReply - (*GetHeadLogRequest)(nil), // 10: net.pb.GetHeadLogRequest - (*PushLogReply)(nil), // 11: net.pb.PushLogReply - (*GetHeadLogReply)(nil), // 12: net.pb.GetHeadLogReply - (*PushLogRequest_Body)(nil), // 13: net.pb.PushLogRequest.Body -} -var file_net_proto_depIdxs = []int32{ - 13, // 0: net.pb.PushLogRequest.body:type_name -> net.pb.PushLogRequest.Body - 0, // 1: net.pb.PushLogRequest.Body.log:type_name -> net.pb.Log - 1, // 2: net.pb.Service.GetDocGraph:input_type -> net.pb.GetDocGraphRequest - 3, // 3: net.pb.Service.PushDocGraph:input_type -> net.pb.PushDocGraphRequest - 5, // 4: net.pb.Service.GetLog:input_type -> net.pb.GetLogRequest - 7, // 5: net.pb.Service.PushLog:input_type -> net.pb.PushLogRequest - 10, // 6: net.pb.Service.GetHeadLog:input_type -> net.pb.GetHeadLogRequest - 2, // 7: net.pb.Service.GetDocGraph:output_type -> net.pb.GetDocGraphReply - 4, // 8: net.pb.Service.PushDocGraph:output_type -> net.pb.PushDocGraphReply - 6, // 9: net.pb.Service.GetLog:output_type -> net.pb.GetLogReply - 11, // 10: net.pb.Service.PushLog:output_type -> net.pb.PushLogReply - 12, // 11: net.pb.Service.GetHeadLog:output_type -> net.pb.GetHeadLogReply - 7, // [7:12] is the sub-list for method output_type - 2, // [2:7] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name -} - -func init() { file_net_proto_init() } -func file_net_proto_init() { - if File_net_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_net_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Log); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*GetDocGraphRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*GetDocGraphReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*PushDocGraphRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*PushDocGraphReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*GetLogRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*GetLogReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*PushLogRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[8].Exporter = func(v any, i int) any { - switch v := v.(*FetchEncryptionKeyRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[9].Exporter = func(v any, i int) any { - switch v := v.(*FetchEncryptionKeyReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[10].Exporter = func(v any, i int) any { - switch v := v.(*GetHeadLogRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[11].Exporter = func(v any, i int) any { - switch v := v.(*PushLogReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[12].Exporter = func(v any, i int) any { - switch v := v.(*GetHeadLogReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_net_proto_msgTypes[13].Exporter = func(v any, i int) any { - switch v := v.(*PushLogRequest_Body); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_net_proto_rawDesc, - NumEnums: 0, - NumMessages: 14, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_net_proto_goTypes, - DependencyIndexes: file_net_proto_depIdxs, - MessageInfos: file_net_proto_msgTypes, - }.Build() - File_net_proto = out.File - file_net_proto_rawDesc = nil - file_net_proto_goTypes = nil - file_net_proto_depIdxs = nil -} diff --git a/net/pb/net.proto b/net/pb/net.proto deleted file mode 100644 index 8dc8fe8a46..0000000000 --- a/net/pb/net.proto +++ /dev/null @@ -1,80 +0,0 @@ -syntax = "proto3"; -package net.pb; - -option go_package = "/;net_pb"; - -// Log represents a thread log. -message Log { - // block is the top-level node's raw data as an ipld.Block. - bytes block = 1; -} - -message GetDocGraphRequest {} - -message GetDocGraphReply {} - -message PushDocGraphRequest {} - -message PushDocGraphReply {} - -message GetLogRequest {} - -message GetLogReply {} - -message PushLogRequest { - Body body = 1; - - message Body { - // docID is the ID of the document that is affected by the log. - bytes docID = 1; - // cid is the CID of the composite of the document. - bytes cid = 2; - // schemaRoot is the SchemaRoot of the collection that the document resides in. - bytes schemaRoot = 3; - // creator is the PeerID of the peer that created the log. - string creator = 4; - // log hold the block that represent version of the document. - Log log = 6; - } -} - -// FetchEncryptionKeyRequest is a request to receive a doc encryption key -// from a peer that holds it. -message FetchEncryptionKeyRequest { - // links is the list of cid links of the blocks containing encryption keys. - repeated bytes links = 1; - // ephemeralPublicKey is an ephemeral public of the requesting peer for deriving shared secret - bytes ephemeralPublicKey = 2; -} - -// FetchEncryptionKeyReply is a response to FetchEncryptionKeyRequest request -// by a peer that holds the requested doc encryption key. -message FetchEncryptionKeyReply { - // links is the list of cid links of the blocks containing encryption keys. - repeated bytes links = 1; - // blocks is the list of blocks containing encryption keys. The order of blocks should match the order of links. - // Every block is encrypted and contains a nonce. - repeated bytes blocks = 2; - // ephemeralPublicKey is an ephemeral public of the responding peer for deriving shared secret - bytes ephemeralPublicKey = 3; -} - -message GetHeadLogRequest {} - -message PushLogReply {} - -message GetHeadLogReply {} - -// Service is the peer-to-peer network API for document sync -service Service { - // GetDocGraph from this peer. - rpc GetDocGraph(GetDocGraphRequest) returns (GetDocGraphReply) {} - // PushDocGraph to this peer. - rpc PushDocGraph(PushDocGraphRequest) returns (PushDocGraphReply) {} - // GetLog from this peer. - rpc GetLog(GetLogRequest) returns (GetLogReply) {} - // PushLog to this peer. - rpc PushLog(PushLogRequest) returns (PushLogReply) {} - // GetHeadLog from this peer - rpc GetHeadLog(GetHeadLogRequest) returns (GetHeadLogReply) {} -} diff --git a/net/pb/net_grpc.pb.go b/net/pb/net_grpc.pb.go deleted file mode 100644 index 84564d6bec..0000000000 --- a/net/pb/net_grpc.pb.go +++ /dev/null @@ -1,276 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.4.0 -// - protoc v5.27.1 -// source: net.proto - -package net_pb - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.62.0 or later. -const _ = grpc.SupportPackageIsVersion8 - -const ( - Service_GetDocGraph_FullMethodName = "/net.pb.Service/GetDocGraph" - Service_PushDocGraph_FullMethodName = "/net.pb.Service/PushDocGraph" - Service_GetLog_FullMethodName = "/net.pb.Service/GetLog" - Service_PushLog_FullMethodName = "/net.pb.Service/PushLog" - Service_GetHeadLog_FullMethodName = "/net.pb.Service/GetHeadLog" -) - -// ServiceClient is the client API for Service service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// Service is the peer-to-peer network API for document sync -type ServiceClient interface { - // GetDocGraph from this peer. - GetDocGraph(ctx context.Context, in *GetDocGraphRequest, opts ...grpc.CallOption) (*GetDocGraphReply, error) - // PushDocGraph to this peer. - PushDocGraph(ctx context.Context, in *PushDocGraphRequest, opts ...grpc.CallOption) (*PushDocGraphReply, error) - // GetLog from this peer. - GetLog(ctx context.Context, in *GetLogRequest, opts ...grpc.CallOption) (*GetLogReply, error) - // PushLog to this peer. - PushLog(ctx context.Context, in *PushLogRequest, opts ...grpc.CallOption) (*PushLogReply, error) - // GetHeadLog from this peer - GetHeadLog(ctx context.Context, in *GetHeadLogRequest, opts ...grpc.CallOption) (*GetHeadLogReply, error) -} - -type serviceClient struct { - cc grpc.ClientConnInterface -} - -func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { - return &serviceClient{cc} -} - -func (c *serviceClient) GetDocGraph(ctx context.Context, in *GetDocGraphRequest, opts ...grpc.CallOption) (*GetDocGraphReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetDocGraphReply) - err := c.cc.Invoke(ctx, Service_GetDocGraph_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) PushDocGraph(ctx context.Context, in *PushDocGraphRequest, opts ...grpc.CallOption) (*PushDocGraphReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(PushDocGraphReply) - err := c.cc.Invoke(ctx, Service_PushDocGraph_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) GetLog(ctx context.Context, in *GetLogRequest, opts ...grpc.CallOption) (*GetLogReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetLogReply) - err := c.cc.Invoke(ctx, Service_GetLog_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) PushLog(ctx context.Context, in *PushLogRequest, opts ...grpc.CallOption) (*PushLogReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(PushLogReply) - err := c.cc.Invoke(ctx, Service_PushLog_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *serviceClient) GetHeadLog(ctx context.Context, in *GetHeadLogRequest, opts ...grpc.CallOption) (*GetHeadLogReply, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetHeadLogReply) - err := c.cc.Invoke(ctx, Service_GetHeadLog_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ServiceServer is the server API for Service service. -// All implementations must embed UnimplementedServiceServer -// for forward compatibility -// -// Service is the peer-to-peer network API for document sync -type ServiceServer interface { - // GetDocGraph from this peer. - GetDocGraph(context.Context, *GetDocGraphRequest) (*GetDocGraphReply, error) - // PushDocGraph to this peer. - PushDocGraph(context.Context, *PushDocGraphRequest) (*PushDocGraphReply, error) - // GetLog from this peer. - GetLog(context.Context, *GetLogRequest) (*GetLogReply, error) - // PushLog to this peer. - PushLog(context.Context, *PushLogRequest) (*PushLogReply, error) - // GetHeadLog from this peer - GetHeadLog(context.Context, *GetHeadLogRequest) (*GetHeadLogReply, error) - mustEmbedUnimplementedServiceServer() -} - -// UnimplementedServiceServer must be embedded to have forward compatible implementations. -type UnimplementedServiceServer struct { -} - -func (UnimplementedServiceServer) GetDocGraph(context.Context, *GetDocGraphRequest) (*GetDocGraphReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetDocGraph not implemented") -} -func (UnimplementedServiceServer) PushDocGraph(context.Context, *PushDocGraphRequest) (*PushDocGraphReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method PushDocGraph not implemented") -} -func (UnimplementedServiceServer) GetLog(context.Context, *GetLogRequest) (*GetLogReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetLog not implemented") -} -func (UnimplementedServiceServer) PushLog(context.Context, *PushLogRequest) (*PushLogReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method PushLog not implemented") -} -func (UnimplementedServiceServer) GetHeadLog(context.Context, *GetHeadLogRequest) (*GetHeadLogReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetHeadLog not implemented") -} -func (UnimplementedServiceServer) mustEmbedUnimplementedServiceServer() {} - -// UnsafeServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ServiceServer will -// result in compilation errors. -type UnsafeServiceServer interface { - mustEmbedUnimplementedServiceServer() -} - -func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer) { - s.RegisterService(&Service_ServiceDesc, srv) -} - -func _Service_GetDocGraph_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetDocGraphRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).GetDocGraph(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Service_GetDocGraph_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).GetDocGraph(ctx, req.(*GetDocGraphRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_PushDocGraph_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PushDocGraphRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).PushDocGraph(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Service_PushDocGraph_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).PushDocGraph(ctx, req.(*PushDocGraphRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_GetLog_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetLogRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).GetLog(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Service_GetLog_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).GetLog(ctx, req.(*GetLogRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_PushLog_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PushLogRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).PushLog(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Service_PushLog_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).PushLog(ctx, req.(*PushLogRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Service_GetHeadLog_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetHeadLogRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ServiceServer).GetHeadLog(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Service_GetHeadLog_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).GetHeadLog(ctx, req.(*GetHeadLogRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Service_ServiceDesc is the grpc.ServiceDesc for Service service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Service_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "net.pb.Service", - HandlerType: (*ServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "GetDocGraph", - Handler: _Service_GetDocGraph_Handler, - }, - { - MethodName: "PushDocGraph", - Handler: _Service_PushDocGraph_Handler, - }, - { - MethodName: "GetLog", - Handler: _Service_GetLog_Handler, - }, - { - MethodName: "PushLog", - Handler: _Service_PushLog_Handler, - }, - { - MethodName: "GetHeadLog", - Handler: _Service_GetHeadLog_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "net.proto", -} diff --git a/net/pb/net_vtproto.pb.go b/net/pb/net_vtproto.pb.go deleted file mode 100644 index bf1c93e8e8..0000000000 --- a/net/pb/net_vtproto.pb.go +++ /dev/null @@ -1,1890 +0,0 @@ -// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. -// protoc-gen-go-vtproto version: v0.6.0 -// source: net.proto - -package net_pb - -import ( - fmt "fmt" - protohelpers "github.com/planetscale/vtprotobuf/protohelpers" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - io "io" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -func (m *Log) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Log) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *Log) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.Block) > 0 { - i -= len(m.Block) - copy(dAtA[i:], m.Block) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Block))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *GetDocGraphRequest) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GetDocGraphRequest) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *GetDocGraphRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - return len(dAtA) - i, nil -} - -func (m *GetDocGraphReply) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GetDocGraphReply) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *GetDocGraphReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - return len(dAtA) - i, nil -} - -func (m *PushDocGraphRequest) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PushDocGraphRequest) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *PushDocGraphRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - return len(dAtA) - i, nil -} - -func (m *PushDocGraphReply) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PushDocGraphReply) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *PushDocGraphReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - return len(dAtA) - i, nil -} - -func (m *GetLogRequest) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GetLogRequest) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *GetLogRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - return len(dAtA) - i, nil -} - -func (m *GetLogReply) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GetLogReply) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *GetLogReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - return len(dAtA) - i, nil -} - -func (m *PushLogRequest_Body) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PushLogRequest_Body) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *PushLogRequest_Body) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if m.Log != nil { - size, err := m.Log.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0x32 - } - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0x22 - } - if len(m.SchemaRoot) > 0 { - i -= len(m.SchemaRoot) - copy(dAtA[i:], m.SchemaRoot) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.SchemaRoot))) - i-- - dAtA[i] = 0x1a - } - if len(m.Cid) > 0 { - i -= len(m.Cid) - copy(dAtA[i:], m.Cid) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Cid))) - i-- - dAtA[i] = 0x12 - } - if len(m.DocID) > 0 { - i -= len(m.DocID) - copy(dAtA[i:], m.DocID) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.DocID))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *PushLogRequest) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PushLogRequest) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *PushLogRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if m.Body != nil { - size, err := m.Body.MarshalToSizedBufferVT(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *FetchEncryptionKeyRequest) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *FetchEncryptionKeyRequest) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *FetchEncryptionKeyRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.EphemeralPublicKey) > 0 { - i -= len(m.EphemeralPublicKey) - copy(dAtA[i:], m.EphemeralPublicKey) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.EphemeralPublicKey))) - i-- - dAtA[i] = 0x12 - } - if len(m.Links) > 0 { - for iNdEx := len(m.Links) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Links[iNdEx]) - copy(dAtA[i:], m.Links[iNdEx]) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Links[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *FetchEncryptionKeyReply) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *FetchEncryptionKeyReply) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *FetchEncryptionKeyReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if len(m.EphemeralPublicKey) > 0 { - i -= len(m.EphemeralPublicKey) - copy(dAtA[i:], m.EphemeralPublicKey) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.EphemeralPublicKey))) - i-- - dAtA[i] = 0x1a - } - if len(m.Blocks) > 0 { - for iNdEx := len(m.Blocks) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Blocks[iNdEx]) - copy(dAtA[i:], m.Blocks[iNdEx]) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Blocks[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - if len(m.Links) > 0 { - for iNdEx := len(m.Links) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Links[iNdEx]) - copy(dAtA[i:], m.Links[iNdEx]) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Links[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *GetHeadLogRequest) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GetHeadLogRequest) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *GetHeadLogRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - return len(dAtA) - i, nil -} - -func (m *PushLogReply) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PushLogReply) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *PushLogReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - return len(dAtA) - i, nil -} - -func (m *GetHeadLogReply) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GetHeadLogReply) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *GetHeadLogReply) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - return len(dAtA) - i, nil -} - -func (m *Log) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Block) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *GetDocGraphRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *GetDocGraphReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *PushDocGraphRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *PushDocGraphReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *GetLogRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *GetLogReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *PushLogRequest_Body) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DocID) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - l = len(m.Cid) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - l = len(m.SchemaRoot) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - l = len(m.Creator) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - if m.Log != nil { - l = m.Log.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *PushLogRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Body != nil { - l = m.Body.SizeVT() - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *FetchEncryptionKeyRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Links) > 0 { - for _, b := range m.Links { - l = len(b) - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - } - l = len(m.EphemeralPublicKey) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *FetchEncryptionKeyReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Links) > 0 { - for _, b := range m.Links { - l = len(b) - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - } - if len(m.Blocks) > 0 { - for _, b := range m.Blocks { - l = len(b) - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - } - l = len(m.EphemeralPublicKey) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - n += len(m.unknownFields) - return n -} - -func (m *GetHeadLogRequest) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *PushLogReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *GetHeadLogReply) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - n += len(m.unknownFields) - return n -} - -func (m *Log) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Log: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Log: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Block", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Block = append(m.Block[:0], dAtA[iNdEx:postIndex]...) - if m.Block == nil { - m.Block = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetDocGraphRequest) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetDocGraphRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetDocGraphRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetDocGraphReply) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetDocGraphReply: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetDocGraphReply: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PushDocGraphRequest) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PushDocGraphRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PushDocGraphRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PushDocGraphReply) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PushDocGraphReply: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PushDocGraphReply: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetLogRequest) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetLogRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetLogRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetLogReply) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetLogReply: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetLogReply: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PushLogRequest_Body) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PushLogRequest_Body: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PushLogRequest_Body: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DocID", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DocID = append(m.DocID[:0], dAtA[iNdEx:postIndex]...) - if m.DocID == nil { - m.DocID = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Cid", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Cid = append(m.Cid[:0], dAtA[iNdEx:postIndex]...) - if m.Cid == nil { - m.Cid = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SchemaRoot", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SchemaRoot = append(m.SchemaRoot[:0], dAtA[iNdEx:postIndex]...) - if m.SchemaRoot == nil { - m.SchemaRoot = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Log", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Log == nil { - m.Log = &Log{} - } - if err := m.Log.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PushLogRequest) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PushLogRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PushLogRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Body == nil { - m.Body = &PushLogRequest_Body{} - } - if err := m.Body.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *FetchEncryptionKeyRequest) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: FetchEncryptionKeyRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: FetchEncryptionKeyRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Links", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Links = append(m.Links, make([]byte, postIndex-iNdEx)) - copy(m.Links[len(m.Links)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EphemeralPublicKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EphemeralPublicKey = append(m.EphemeralPublicKey[:0], dAtA[iNdEx:postIndex]...) - if m.EphemeralPublicKey == nil { - m.EphemeralPublicKey = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *FetchEncryptionKeyReply) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: FetchEncryptionKeyReply: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: FetchEncryptionKeyReply: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Links", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Links = append(m.Links, make([]byte, postIndex-iNdEx)) - copy(m.Links[len(m.Links)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Blocks", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Blocks = append(m.Blocks, make([]byte, postIndex-iNdEx)) - copy(m.Blocks[len(m.Blocks)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EphemeralPublicKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EphemeralPublicKey = append(m.EphemeralPublicKey[:0], dAtA[iNdEx:postIndex]...) - if m.EphemeralPublicKey == nil { - m.EphemeralPublicKey = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetHeadLogRequest) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetHeadLogRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetHeadLogRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PushLogReply) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PushLogReply: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PushLogReply: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetHeadLogReply) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetHeadLogReply: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetHeadLogReply: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} diff --git a/net/peer.go b/net/peer.go index 24976ed388..7b855a1ca2 100644 --- a/net/peer.go +++ b/net/peer.go @@ -38,7 +38,6 @@ import ( "github.com/sourcenetwork/defradb/errors" "github.com/sourcenetwork/defradb/event" corenet "github.com/sourcenetwork/defradb/internal/core/net" - pb "github.com/sourcenetwork/defradb/net/pb" ) // Peer is a DefraDB Peer node which exposes all the LibP2P host/peer functionality @@ -163,7 +162,7 @@ func NewPeer( // register the P2P gRPC server go func() { - pb.RegisterServiceServer(p.p2pRPC, p.server) + registerServiceServer(p.p2pRPC, p.server) if err := p.p2pRPC.Serve(p2pListener); err != nil && !errors.Is(err, grpc.ErrServerStopped) { log.ErrorE("Fatal P2P RPC server error", err) @@ -280,17 +279,12 @@ func (p *Peer) RegisterNewDocument( return err } - // publish log - req := &pb.PushLogRequest{ - Body: &pb.PushLogRequest_Body{ - DocID: []byte(docID.String()), - Cid: c.Bytes(), - SchemaRoot: []byte(schemaRoot), - Creator: p.host.ID().String(), - Log: &pb.Log{ - Block: rawBlock, - }, - }, + req := &pushLogRequest{ + DocID: docID.String(), + CID: c.Bytes(), + SchemaRoot: schemaRoot, + Creator: p.host.ID().String(), + Block: rawBlock, } return p.server.publishLog(ctx, schemaRoot, req) @@ -315,26 +309,21 @@ func (p *Peer) handleDocCreateLog(evt event.Update) error { } func (p *Peer) handleDocUpdateLog(evt event.Update) error { - docID, err := client.NewDocIDFromString(evt.DocID) + // push to each peer (replicator) + p.pushLogToReplicators(evt) + + _, err := client.NewDocIDFromString(evt.DocID) if err != nil { return NewErrFailedToGetDocID(err) } - body := &pb.PushLogRequest_Body{ - DocID: []byte(docID.String()), - Cid: evt.Cid.Bytes(), - SchemaRoot: []byte(evt.SchemaRoot), + req := &pushLogRequest{ + DocID: evt.DocID, + CID: evt.Cid.Bytes(), + SchemaRoot: evt.SchemaRoot, Creator: p.host.ID().String(), - Log: &pb.Log{ - Block: evt.Block, - }, + Block: evt.Block, } - req := &pb.PushLogRequest{ - Body: body, - } - - // push to each peer (replicator) - p.pushLogToReplicators(evt) if err := p.server.publishLog(p.ctx, evt.DocID, req); err != nil { return NewErrPublishingToDocIDTopic(err, evt.Cid.String(), evt.DocID) diff --git a/net/server.go b/net/server.go index 42ff15f5fb..2e4939c77f 100644 --- a/net/server.go +++ b/net/server.go @@ -17,6 +17,7 @@ import ( "fmt" "sync" + "github.com/fxamacker/cbor/v2" cid "github.com/ipfs/go-cid" libpeer "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/core/peerstore" @@ -25,13 +26,11 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" grpcpeer "google.golang.org/grpc/peer" - "google.golang.org/protobuf/proto" "github.com/sourcenetwork/defradb/client" "github.com/sourcenetwork/defradb/errors" "github.com/sourcenetwork/defradb/event" coreblock "github.com/sourcenetwork/defradb/internal/core/block" - pb "github.com/sourcenetwork/defradb/net/pb" ) // server is the request/response instance for all P2P RPC communication. @@ -49,8 +48,6 @@ type server struct { mu sync.Mutex conns map[libpeer.ID]*grpc.ClientConn - - pb.UnimplementedServiceServer } // pubsubTopic is a wrapper of rpc.Topic to be able to track if the topic has @@ -74,6 +71,7 @@ func newServer(p *Peer, opts ...grpc.DialOption) (*server, error) { defaultOpts := []grpc.DialOption{ s.getLibp2pDialer(), grpc.WithTransportCredentials(cred), + grpc.WithDefaultCallOptions(grpc.CallContentSubtype(cborCodecName)), } s.opts = append(defaultOpts, opts...) @@ -84,43 +82,43 @@ func newServer(p *Peer, opts ...grpc.DialOption) (*server, error) { // GetDocGraph receives a get graph request func (s *server) GetDocGraph( ctx context.Context, - req *pb.GetDocGraphRequest, -) (*pb.GetDocGraphReply, error) { + req *getDocGraphRequest, +) (*getDocGraphReply, error) { return nil, nil } // PushDocGraph receives a push graph request func (s *server) PushDocGraph( ctx context.Context, - req *pb.PushDocGraphRequest, -) (*pb.PushDocGraphReply, error) { + req *pushDocGraphRequest, +) (*pushDocGraphReply, error) { return nil, nil } // GetLog receives a get log request -func (s *server) GetLog(ctx context.Context, req *pb.GetLogRequest) (*pb.GetLogReply, error) { +func (s *server) GetLog(ctx context.Context, req *getLogRequest) (*getLogReply, error) { return nil, nil } // PushLog receives a push log request -func (s *server) PushLog(ctx context.Context, req *pb.PushLogRequest) (*pb.PushLogReply, error) { +func (s *server) PushLog(ctx context.Context, req *pushLogRequest) (*pushLogReply, error) { pid, err := peerIDFromContext(ctx) if err != nil { return nil, err } - headCID, err := cid.Cast(req.Body.Cid) + headCID, err := cid.Cast(req.CID) if err != nil { return nil, err } - docID, err := client.NewDocIDFromString(string(req.Body.DocID)) + docID, err := client.NewDocIDFromString(req.DocID) if err != nil { return nil, err } - byPeer, err := libpeer.Decode(req.Body.Creator) + byPeer, err := libpeer.Decode(req.Creator) if err != nil { return nil, err } - block, err := coreblock.GetFromBytes(req.Body.Log.Block) + block, err := coreblock.GetFromBytes(req.Block) if err != nil { return nil, err } @@ -145,7 +143,7 @@ func (s *server) PushLog(ctx context.Context, req *pb.PushLogRequest) (*pb.PushL // Once processed, subscribe to the DocID topic on the pubsub network unless we already // subscribed to the collection. - if !s.hasPubSubTopic(string(req.Body.SchemaRoot)) { + if !s.hasPubSubTopic(req.SchemaRoot) { err = s.addPubSubTopic(docID.String(), true, nil) if err != nil { return nil, err @@ -157,17 +155,17 @@ func (s *server) PushLog(ctx context.Context, req *pb.PushLogRequest) (*pb.PushL ByPeer: byPeer, FromPeer: pid, Cid: headCID, - SchemaRoot: string(req.Body.SchemaRoot), + SchemaRoot: req.SchemaRoot, })) - return &pb.PushLogReply{}, nil + return &pushLogReply{}, nil } // GetHeadLog receives a get head log request func (s *server) GetHeadLog( ctx context.Context, - req *pb.GetHeadLogRequest, -) (*pb.GetHeadLogReply, error) { + req *getHeadLogRequest, +) (*getHeadLogReply, error) { return nil, nil } @@ -267,7 +265,7 @@ func (s *server) removeAllPubsubTopics() error { // publishLog publishes the given PushLogRequest object on the PubSub network via the // corresponding topic -func (s *server) publishLog(ctx context.Context, topic string, req *pb.PushLogRequest) error { +func (s *server) publishLog(ctx context.Context, topic string, req *pushLogRequest) error { log.InfoContext(ctx, "Publish log", corelog.String("PeerID", s.peer.PeerID().String()), corelog.String("Topic", topic)) @@ -286,7 +284,7 @@ func (s *server) publishLog(ctx context.Context, topic string, req *pb.PushLogRe return s.publishLog(ctx, topic, req) } - data, err := req.MarshalVT() + data, err := cbor.Marshal(req) if err != nil { return errors.Wrap("failed to marshal pubsub message", err) } @@ -305,8 +303,8 @@ func (s *server) pubSubMessageHandler(from libpeer.ID, topic string, msg []byte) corelog.Any("SenderId", from), corelog.String("Topic", topic)) - req := new(pb.PushLogRequest) - if err := proto.Unmarshal(msg, req); err != nil { + req := &pushLogRequest{} + if err := cbor.Unmarshal(msg, req); err != nil { log.ErrorE("Failed to unmarshal pubsub message %s", err) return nil, err } diff --git a/net/server_test.go b/net/server_test.go index 11a13604b1..4dc6428205 100644 --- a/net/server_test.go +++ b/net/server_test.go @@ -22,7 +22,6 @@ import ( "github.com/sourcenetwork/defradb/client" "github.com/sourcenetwork/defradb/errors" "github.com/sourcenetwork/defradb/internal/core" - net_pb "github.com/sourcenetwork/defradb/net/pb" ) func TestNewServerSimple(t *testing.T) { @@ -39,7 +38,7 @@ func TestGetDocGraph(t *testing.T) { db, p := newTestPeer(ctx, t) defer db.Close() defer p.Close() - r, err := p.server.GetDocGraph(ctx, &net_pb.GetDocGraphRequest{}) + r, err := p.server.GetDocGraph(ctx, &getDocGraphRequest{}) require.Nil(t, r) require.Nil(t, err) } @@ -49,7 +48,7 @@ func TestPushDocGraph(t *testing.T) { db, p := newTestPeer(ctx, t) defer db.Close() defer p.Close() - r, err := p.server.PushDocGraph(ctx, &net_pb.PushDocGraphRequest{}) + r, err := p.server.PushDocGraph(ctx, &pushDocGraphRequest{}) require.Nil(t, r) require.Nil(t, err) } @@ -59,7 +58,7 @@ func TestGetLog(t *testing.T) { db, p := newTestPeer(ctx, t) defer db.Close() defer p.Close() - r, err := p.server.GetLog(ctx, &net_pb.GetLogRequest{}) + r, err := p.server.GetLog(ctx, &getLogRequest{}) require.Nil(t, r) require.Nil(t, err) } @@ -69,7 +68,7 @@ func TestGetHeadLog(t *testing.T) { db, p := newTestPeer(ctx, t) defer db.Close() defer p.Close() - r, err := p.server.GetHeadLog(ctx, &net_pb.GetHeadLogRequest{}) + r, err := p.server.GetHeadLog(ctx, &getHeadLogRequest{}) require.Nil(t, r) require.Nil(t, err) } @@ -126,16 +125,12 @@ func TestPushLog(t *testing.T) { b, err := db.Blockstore().AsIPLDStorage().Get(ctx, headCID.KeyString()) require.NoError(t, err) - _, err = p.server.PushLog(ctx, &net_pb.PushLogRequest{ - Body: &net_pb.PushLogRequest_Body{ - DocID: []byte(doc.ID().String()), - Cid: headCID.Bytes(), - SchemaRoot: []byte(col.SchemaRoot()), - Creator: p.PeerID().String(), - Log: &net_pb.Log{ - Block: b, - }, - }, + _, err = p.server.PushLog(ctx, &pushLogRequest{ + DocID: doc.ID().String(), + CID: headCID.Bytes(), + SchemaRoot: col.SchemaRoot(), + Creator: p.PeerID().String(), + Block: b, }) require.NoError(t, err) }