diff --git a/cmd/root.go b/cmd/root.go index 4dc401b0..94066181 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -3,6 +3,7 @@ package cmd import ( "context" "crypto/rand" + "encoding/binary" "encoding/hex" "fmt" "net" @@ -38,11 +39,9 @@ func (dbStore *DBStore) Put(message *protocol.WakuMessage) error { func (dbStore *DBStore) GetAll() ([]*protocol.WakuMessage, error) { fmt.Println("TODO: Implement MessageProvider.GetAll. Returning a sample message") exampleMessage := new(protocol.WakuMessage) - var contentTopic uint32 = 1 - var version uint32 = 0 - exampleMessage.ContentTopic = &contentTopic + exampleMessage.ContentTopic = 1 exampleMessage.Payload = []byte("Hello!") - exampleMessage.Version = &version + exampleMessage.Version = 0 return []*protocol.WakuMessage{exampleMessage}, nil } @@ -112,7 +111,9 @@ var rootCmd = &cobra.Command{ return } - response, err := wakuNode.Query(1, true, 10) + var DefaultContentTopic uint32 = binary.LittleEndian.Uint32([]byte("dingpu")) + + response, err := wakuNode.Query(DefaultContentTopic, true, 10) if err != nil { fmt.Println(err) return diff --git a/go.mod b/go.mod index 07ddae94..9ba5e6f1 100644 --- a/go.mod +++ b/go.mod @@ -7,10 +7,10 @@ require ( github.com/ethereum/go-ethereum v1.9.5 github.com/golang/protobuf v1.4.1 github.com/ipfs/go-log v1.0.4 - github.com/ipfs/go-log/v2 v2.1.1 github.com/libp2p/go-libp2p v0.13.0 github.com/libp2p/go-libp2p-connmgr v0.2.4 github.com/libp2p/go-libp2p-core v0.8.5 + github.com/libp2p/go-msgio v0.0.6 github.com/magiconair/properties v1.8.4 // indirect github.com/mitchellh/mapstructure v1.4.1 // indirect github.com/multiformats/go-multiaddr v0.3.1 @@ -24,6 +24,6 @@ require ( github.com/status-im/go-wakurelay-pubsub v0.4.2 golang.org/x/sys v0.0.0-20210317225723-c4fcb01b228e // indirect golang.org/x/text v0.3.5 // indirect - google.golang.org/protobuf v1.25.0 + google.golang.org/protobuf v1.25.0 // indirect gopkg.in/ini.v1 v1.62.0 // indirect ) diff --git a/waku/v2/node/waku_payload.go b/waku/v2/node/waku_payload.go index efe9c94c..776b0deb 100644 --- a/waku/v2/node/waku_payload.go +++ b/waku/v2/node/waku_payload.go @@ -87,7 +87,7 @@ func (payload Payload) Encode(version uint32) ([]byte, error) { } func DecodePayload(message *protocol.WakuMessage, keyInfo *KeyInfo) (*DecodedPayload, error) { - switch *message.Version { + switch message.Version { case uint32(0): return &DecodedPayload{Data: message.Payload}, nil case uint32(1): diff --git a/waku/v2/node/wakunode2.go b/waku/v2/node/wakunode2.go index d65c0ba5..c0374443 100644 --- a/waku/v2/node/wakunode2.go +++ b/waku/v2/node/wakunode2.go @@ -196,7 +196,7 @@ func (w *WakuNode) AddStorePeer(address string) error { return w.store.AddPeer(info.ID, info.Addrs) } -func (w *WakuNode) Query(contentTopic uint32, asc bool, pageSize int64) (*protocol.HistoryResponse, error) { +func (w *WakuNode) Query(contentTopic uint32, asc bool, pageSize uint64) (*protocol.HistoryResponse, error) { if w.store == nil { return nil, errors.New("WakuStore is not set") } diff --git a/waku/v2/protocol/waku_message.pb.go b/waku/v2/protocol/waku_message.pb.go index 726867f0..df775627 100644 --- a/waku/v2/protocol/waku_message.pb.go +++ b/waku/v2/protocol/waku_message.pb.go @@ -1,192 +1,481 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0 -// protoc v3.14.0 +// Code generated by protoc-gen-gogo. DO NOT EDIT. // source: waku_message.proto package protocol import ( + encoding_binary "encoding/binary" + fmt "fmt" proto "github.com/golang/protobuf/proto" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" + io "io" + math "math" + math_bits "math/bits" ) -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) -) +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type WakuMessage struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3,oneof" json:"payload,omitempty"` - ContentTopic *uint32 `protobuf:"varint,2,opt,name=contentTopic,proto3,oneof" json:"contentTopic,omitempty"` - Version *uint32 `protobuf:"varint,3,opt,name=version,proto3,oneof" json:"version,omitempty"` - Proof []byte `protobuf:"bytes,4,opt,name=proof,proto3,oneof" json:"proof,omitempty"` - Timestamp *float64 `protobuf:"fixed64,5,opt,name=timestamp,proto3,oneof" json:"timestamp,omitempty"` + Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` + ContentTopic uint32 `protobuf:"varint,2,opt,name=contentTopic,proto3" json:"contentTopic,omitempty"` + Version uint32 `protobuf:"varint,3,opt,name=version,proto3" json:"version,omitempty"` + Proof []byte `protobuf:"bytes,4,opt,name=proof,proto3" json:"proof,omitempty"` + Timestamp float64 `protobuf:"fixed64,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *WakuMessage) Reset() { - *x = WakuMessage{} - if protoimpl.UnsafeEnabled { - mi := &file_waku_message_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *WakuMessage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*WakuMessage) ProtoMessage() {} - -func (x *WakuMessage) ProtoReflect() protoreflect.Message { - mi := &file_waku_message_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 WakuMessage.ProtoReflect.Descriptor instead. +func (m *WakuMessage) Reset() { *m = WakuMessage{} } +func (m *WakuMessage) String() string { return proto.CompactTextString(m) } +func (*WakuMessage) ProtoMessage() {} func (*WakuMessage) Descriptor() ([]byte, []int) { - return file_waku_message_proto_rawDescGZIP(), []int{0} + return fileDescriptor_6f0a20862b3bf714, []int{0} +} +func (m *WakuMessage) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *WakuMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_WakuMessage.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *WakuMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_WakuMessage.Merge(m, src) +} +func (m *WakuMessage) XXX_Size() int { + return m.Size() +} +func (m *WakuMessage) XXX_DiscardUnknown() { + xxx_messageInfo_WakuMessage.DiscardUnknown(m) } -func (x *WakuMessage) GetPayload() []byte { - if x != nil { - return x.Payload +var xxx_messageInfo_WakuMessage proto.InternalMessageInfo + +func (m *WakuMessage) GetPayload() []byte { + if m != nil { + return m.Payload } return nil } -func (x *WakuMessage) GetContentTopic() uint32 { - if x != nil && x.ContentTopic != nil { - return *x.ContentTopic +func (m *WakuMessage) GetContentTopic() uint32 { + if m != nil { + return m.ContentTopic } return 0 } -func (x *WakuMessage) GetVersion() uint32 { - if x != nil && x.Version != nil { - return *x.Version +func (m *WakuMessage) GetVersion() uint32 { + if m != nil { + return m.Version } return 0 } -func (x *WakuMessage) GetProof() []byte { - if x != nil { - return x.Proof +func (m *WakuMessage) GetProof() []byte { + if m != nil { + return m.Proof } return nil } -func (x *WakuMessage) GetTimestamp() float64 { - if x != nil && x.Timestamp != nil { - return *x.Timestamp +func (m *WakuMessage) GetTimestamp() float64 { + if m != nil { + return m.Timestamp } return 0 } -var File_waku_message_proto protoreflect.FileDescriptor +func init() { + proto.RegisterType((*WakuMessage)(nil), "protocol.WakuMessage") +} -var file_waku_message_proto_rawDesc = []byte{ - 0x0a, 0x12, 0x77, 0x61, 0x6b, 0x75, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x22, 0xf3, - 0x01, 0x0a, 0x0b, 0x57, 0x61, 0x6b, 0x75, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1d, - 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x48, - 0x00, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x88, 0x01, 0x01, 0x12, 0x27, 0x0a, - 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0d, 0x48, 0x01, 0x52, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x6f, - 0x70, 0x69, 0x63, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x48, 0x02, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x19, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0c, 0x48, 0x03, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x88, 0x01, 0x01, - 0x12, 0x21, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x01, 0x48, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x42, - 0x0f, 0x0a, 0x0d, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x6f, 0x70, 0x69, 0x63, - 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0x0a, 0x06, - 0x5f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +func init() { proto.RegisterFile("waku_message.proto", fileDescriptor_6f0a20862b3bf714) } + +var fileDescriptor_6f0a20862b3bf714 = []byte{ + // 183 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2a, 0x4f, 0xcc, 0x2e, + 0x8d, 0xcf, 0x4d, 0x2d, 0x2e, 0x4e, 0x4c, 0x4f, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, + 0x00, 0x53, 0xc9, 0xf9, 0x39, 0x4a, 0x33, 0x19, 0xb9, 0xb8, 0xc3, 0x13, 0xb3, 0x4b, 0x7d, 0x21, + 0xf2, 0x42, 0x12, 0x5c, 0xec, 0x05, 0x89, 0x95, 0x39, 0xf9, 0x89, 0x29, 0x12, 0x8c, 0x0a, 0x8c, + 0x1a, 0x3c, 0x41, 0x30, 0xae, 0x90, 0x12, 0x17, 0x4f, 0x72, 0x7e, 0x5e, 0x49, 0x6a, 0x5e, 0x49, + 0x48, 0x7e, 0x41, 0x66, 0xb2, 0x04, 0x93, 0x02, 0xa3, 0x06, 0x6f, 0x10, 0x8a, 0x18, 0x48, 0x77, + 0x59, 0x6a, 0x51, 0x71, 0x66, 0x7e, 0x9e, 0x04, 0x33, 0x58, 0x1a, 0xc6, 0x15, 0x12, 0xe1, 0x62, + 0x2d, 0x28, 0xca, 0xcf, 0x4f, 0x93, 0x60, 0x01, 0x9b, 0x0a, 0xe1, 0x08, 0xc9, 0x70, 0x71, 0x96, + 0x64, 0xe6, 0xa6, 0x16, 0x97, 0x24, 0xe6, 0x16, 0x48, 0xb0, 0x2a, 0x30, 0x6a, 0x30, 0x06, 0x21, + 0x04, 0x9c, 0x04, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, + 0x19, 0x8f, 0xe5, 0x18, 0x92, 0xd8, 0xc0, 0xee, 0x36, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x54, + 0xc5, 0x11, 0x54, 0xd4, 0x00, 0x00, 0x00, +} + +func (m *WakuMessage) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *WakuMessage) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *WakuMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Timestamp != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.Timestamp)))) + i-- + dAtA[i] = 0x29 + } + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintWakuMessage(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x22 + } + if m.Version != 0 { + i = encodeVarintWakuMessage(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x18 + } + if m.ContentTopic != 0 { + i = encodeVarintWakuMessage(dAtA, i, uint64(m.ContentTopic)) + i-- + dAtA[i] = 0x10 + } + if len(m.Payload) > 0 { + i -= len(m.Payload) + copy(dAtA[i:], m.Payload) + i = encodeVarintWakuMessage(dAtA, i, uint64(len(m.Payload))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintWakuMessage(dAtA []byte, offset int, v uint64) int { + offset -= sovWakuMessage(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *WakuMessage) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Payload) + if l > 0 { + n += 1 + l + sovWakuMessage(uint64(l)) + } + if m.ContentTopic != 0 { + n += 1 + sovWakuMessage(uint64(m.ContentTopic)) + } + if m.Version != 0 { + n += 1 + sovWakuMessage(uint64(m.Version)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovWakuMessage(uint64(l)) + } + if m.Timestamp != 0 { + n += 9 + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovWakuMessage(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozWakuMessage(x uint64) (n int) { + return sovWakuMessage(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *WakuMessage) Unmarshal(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 ErrIntOverflowWakuMessage + } + 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: WakuMessage: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: WakuMessage: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuMessage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthWakuMessage + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthWakuMessage + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) + if m.Payload == nil { + m.Payload = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ContentTopic", wireType) + } + m.ContentTopic = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuMessage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ContentTopic |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuMessage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuMessage + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthWakuMessage + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthWakuMessage + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Proof = append(m.Proof[:0], dAtA[iNdEx:postIndex]...) + if m.Proof == nil { + m.Proof = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.Timestamp = float64(math.Float64frombits(v)) + default: + iNdEx = preIndex + skippy, err := skipWakuMessage(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthWakuMessage + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipWakuMessage(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowWakuMessage + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowWakuMessage + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowWakuMessage + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthWakuMessage + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupWakuMessage + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthWakuMessage + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF } var ( - file_waku_message_proto_rawDescOnce sync.Once - file_waku_message_proto_rawDescData = file_waku_message_proto_rawDesc + ErrInvalidLengthWakuMessage = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowWakuMessage = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupWakuMessage = fmt.Errorf("proto: unexpected end of group") ) - -func file_waku_message_proto_rawDescGZIP() []byte { - file_waku_message_proto_rawDescOnce.Do(func() { - file_waku_message_proto_rawDescData = protoimpl.X.CompressGZIP(file_waku_message_proto_rawDescData) - }) - return file_waku_message_proto_rawDescData -} - -var file_waku_message_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_waku_message_proto_goTypes = []interface{}{ - (*WakuMessage)(nil), // 0: protocol.WakuMessage -} -var file_waku_message_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_waku_message_proto_init() } -func file_waku_message_proto_init() { - if File_waku_message_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_waku_message_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WakuMessage); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_waku_message_proto_msgTypes[0].OneofWrappers = []interface{}{} - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_waku_message_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_waku_message_proto_goTypes, - DependencyIndexes: file_waku_message_proto_depIdxs, - MessageInfos: file_waku_message_proto_msgTypes, - }.Build() - File_waku_message_proto = out.File - file_waku_message_proto_rawDesc = nil - file_waku_message_proto_goTypes = nil - file_waku_message_proto_depIdxs = nil -} diff --git a/waku/v2/protocol/waku_message.proto b/waku/v2/protocol/waku_message.proto index 1e5b5ab5..c09e7401 100644 --- a/waku/v2/protocol/waku_message.proto +++ b/waku/v2/protocol/waku_message.proto @@ -3,9 +3,9 @@ syntax = "proto3"; package protocol; message WakuMessage { - optional bytes payload = 1; - optional uint32 contentTopic = 2; - optional uint32 version = 3; - optional bytes proof = 4; - optional double timestamp = 5; + bytes payload = 1; + uint32 contentTopic = 2; + uint32 version = 3; + bytes proof = 4; + double timestamp = 5; } \ No newline at end of file diff --git a/waku/v2/protocol/waku_store.pb.go b/waku/v2/protocol/waku_store.pb.go index 2e966cc4..348f722c 100644 --- a/waku/v2/protocol/waku_store.pb.go +++ b/waku/v2/protocol/waku_store.pb.go @@ -1,542 +1,1567 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0 -// protoc v3.14.0 +// Code generated by protoc-gen-gogo. DO NOT EDIT. // source: waku_store.proto package protocol import ( + encoding_binary "encoding/binary" + fmt "fmt" proto "github.com/golang/protobuf/proto" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" + io "io" + math "math" + math_bits "math/bits" ) -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) -) +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type PagingInfo_Direction int32 const ( - PagingInfo_FORWARD PagingInfo_Direction = 0 - PagingInfo_BACKWARD PagingInfo_Direction = 1 + PagingInfo_BACKWARD PagingInfo_Direction = 0 + PagingInfo_FORWARD PagingInfo_Direction = 1 ) -// Enum value maps for PagingInfo_Direction. -var ( - PagingInfo_Direction_name = map[int32]string{ - 0: "FORWARD", - 1: "BACKWARD", - } - PagingInfo_Direction_value = map[string]int32{ - "FORWARD": 0, - "BACKWARD": 1, - } -) +var PagingInfo_Direction_name = map[int32]string{ + 0: "BACKWARD", + 1: "FORWARD", +} -func (x PagingInfo_Direction) Enum() *PagingInfo_Direction { - p := new(PagingInfo_Direction) - *p = x - return p +var PagingInfo_Direction_value = map[string]int32{ + "BACKWARD": 0, + "FORWARD": 1, } func (x PagingInfo_Direction) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) + return proto.EnumName(PagingInfo_Direction_name, int32(x)) } -func (PagingInfo_Direction) Descriptor() protoreflect.EnumDescriptor { - return file_waku_store_proto_enumTypes[0].Descriptor() -} - -func (PagingInfo_Direction) Type() protoreflect.EnumType { - return &file_waku_store_proto_enumTypes[0] -} - -func (x PagingInfo_Direction) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use PagingInfo_Direction.Descriptor instead. func (PagingInfo_Direction) EnumDescriptor() ([]byte, []int) { - return file_waku_store_proto_rawDescGZIP(), []int{1, 0} + return fileDescriptor_ca6891f77a46e680, []int{1, 0} } type Index struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Digest []byte `protobuf:"bytes,1,opt,name=digest,proto3" json:"digest,omitempty"` - ReceivedTime float64 `protobuf:"fixed64,2,opt,name=receivedTime,proto3" json:"receivedTime,omitempty"` + Digest []byte `protobuf:"bytes,1,opt,name=digest,proto3" json:"digest,omitempty"` + ReceivedTime float64 `protobuf:"fixed64,2,opt,name=receivedTime,proto3" json:"receivedTime,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *Index) Reset() { - *x = Index{} - if protoimpl.UnsafeEnabled { - mi := &file_waku_store_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Index) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Index) ProtoMessage() {} - -func (x *Index) ProtoReflect() protoreflect.Message { - mi := &file_waku_store_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 Index.ProtoReflect.Descriptor instead. +func (m *Index) Reset() { *m = Index{} } +func (m *Index) String() string { return proto.CompactTextString(m) } +func (*Index) ProtoMessage() {} func (*Index) Descriptor() ([]byte, []int) { - return file_waku_store_proto_rawDescGZIP(), []int{0} + return fileDescriptor_ca6891f77a46e680, []int{0} +} +func (m *Index) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Index) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Index.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Index) XXX_Merge(src proto.Message) { + xxx_messageInfo_Index.Merge(m, src) +} +func (m *Index) XXX_Size() int { + return m.Size() +} +func (m *Index) XXX_DiscardUnknown() { + xxx_messageInfo_Index.DiscardUnknown(m) } -func (x *Index) GetDigest() []byte { - if x != nil { - return x.Digest +var xxx_messageInfo_Index proto.InternalMessageInfo + +func (m *Index) GetDigest() []byte { + if m != nil { + return m.Digest } return nil } -func (x *Index) GetReceivedTime() float64 { - if x != nil { - return x.ReceivedTime +func (m *Index) GetReceivedTime() float64 { + if m != nil { + return m.ReceivedTime } return 0 } type PagingInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - PageSize int64 `protobuf:"varint,1,opt,name=pageSize,proto3" json:"pageSize,omitempty"` - Cursor *Index `protobuf:"bytes,2,opt,name=cursor,proto3" json:"cursor,omitempty"` - Direction PagingInfo_Direction `protobuf:"varint,3,opt,name=direction,proto3,enum=protocol.PagingInfo_Direction" json:"direction,omitempty"` + PageSize uint64 `protobuf:"varint,1,opt,name=pageSize,proto3" json:"pageSize,omitempty"` + Cursor *Index `protobuf:"bytes,2,opt,name=cursor,proto3" json:"cursor,omitempty"` + Direction PagingInfo_Direction `protobuf:"varint,3,opt,name=direction,proto3,enum=protocol.PagingInfo_Direction" json:"direction,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *PagingInfo) Reset() { - *x = PagingInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_waku_store_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *PagingInfo) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PagingInfo) ProtoMessage() {} - -func (x *PagingInfo) ProtoReflect() protoreflect.Message { - mi := &file_waku_store_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 PagingInfo.ProtoReflect.Descriptor instead. +func (m *PagingInfo) Reset() { *m = PagingInfo{} } +func (m *PagingInfo) String() string { return proto.CompactTextString(m) } +func (*PagingInfo) ProtoMessage() {} func (*PagingInfo) Descriptor() ([]byte, []int) { - return file_waku_store_proto_rawDescGZIP(), []int{1} + return fileDescriptor_ca6891f77a46e680, []int{1} +} +func (m *PagingInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PagingInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PagingInfo.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PagingInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_PagingInfo.Merge(m, src) +} +func (m *PagingInfo) XXX_Size() int { + return m.Size() +} +func (m *PagingInfo) XXX_DiscardUnknown() { + xxx_messageInfo_PagingInfo.DiscardUnknown(m) } -func (x *PagingInfo) GetPageSize() int64 { - if x != nil { - return x.PageSize +var xxx_messageInfo_PagingInfo proto.InternalMessageInfo + +func (m *PagingInfo) GetPageSize() uint64 { + if m != nil { + return m.PageSize } return 0 } -func (x *PagingInfo) GetCursor() *Index { - if x != nil { - return x.Cursor +func (m *PagingInfo) GetCursor() *Index { + if m != nil { + return m.Cursor } return nil } -func (x *PagingInfo) GetDirection() PagingInfo_Direction { - if x != nil { - return x.Direction +func (m *PagingInfo) GetDirection() PagingInfo_Direction { + if m != nil { + return m.Direction } - return PagingInfo_FORWARD + return PagingInfo_BACKWARD } type HistoryQuery struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Topics []uint32 `protobuf:"varint,1,rep,packed,name=topics,proto3" json:"topics,omitempty"` - PagingInfo *PagingInfo `protobuf:"bytes,2,opt,name=pagingInfo,proto3,oneof" json:"pagingInfo,omitempty"` // used for pagination + Topics []uint32 `protobuf:"varint,1,rep,packed,name=topics,proto3" json:"topics,omitempty"` + PagingInfo *PagingInfo `protobuf:"bytes,2,opt,name=pagingInfo,proto3" json:"pagingInfo,omitempty"` + StartTime float64 `protobuf:"fixed64,3,opt,name=startTime,proto3" json:"startTime,omitempty"` + EndTime float64 `protobuf:"fixed64,4,opt,name=endTime,proto3" json:"endTime,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *HistoryQuery) Reset() { - *x = HistoryQuery{} - if protoimpl.UnsafeEnabled { - mi := &file_waku_store_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HistoryQuery) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HistoryQuery) ProtoMessage() {} - -func (x *HistoryQuery) ProtoReflect() protoreflect.Message { - mi := &file_waku_store_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 HistoryQuery.ProtoReflect.Descriptor instead. +func (m *HistoryQuery) Reset() { *m = HistoryQuery{} } +func (m *HistoryQuery) String() string { return proto.CompactTextString(m) } +func (*HistoryQuery) ProtoMessage() {} func (*HistoryQuery) Descriptor() ([]byte, []int) { - return file_waku_store_proto_rawDescGZIP(), []int{2} + return fileDescriptor_ca6891f77a46e680, []int{2} +} +func (m *HistoryQuery) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *HistoryQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_HistoryQuery.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *HistoryQuery) XXX_Merge(src proto.Message) { + xxx_messageInfo_HistoryQuery.Merge(m, src) +} +func (m *HistoryQuery) XXX_Size() int { + return m.Size() +} +func (m *HistoryQuery) XXX_DiscardUnknown() { + xxx_messageInfo_HistoryQuery.DiscardUnknown(m) } -func (x *HistoryQuery) GetTopics() []uint32 { - if x != nil { - return x.Topics +var xxx_messageInfo_HistoryQuery proto.InternalMessageInfo + +func (m *HistoryQuery) GetTopics() []uint32 { + if m != nil { + return m.Topics } return nil } -func (x *HistoryQuery) GetPagingInfo() *PagingInfo { - if x != nil { - return x.PagingInfo +func (m *HistoryQuery) GetPagingInfo() *PagingInfo { + if m != nil { + return m.PagingInfo } return nil } +func (m *HistoryQuery) GetStartTime() float64 { + if m != nil { + return m.StartTime + } + return 0 +} + +func (m *HistoryQuery) GetEndTime() float64 { + if m != nil { + return m.EndTime + } + return 0 +} + type HistoryResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Messages []*WakuMessage `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"` - PagingInfo *PagingInfo `protobuf:"bytes,2,opt,name=pagingInfo,proto3,oneof" json:"pagingInfo,omitempty"` // used for pagination + Messages []*WakuMessage `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"` + PagingInfo *PagingInfo `protobuf:"bytes,2,opt,name=pagingInfo,proto3" json:"pagingInfo,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *HistoryResponse) Reset() { - *x = HistoryResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_waku_store_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HistoryResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HistoryResponse) ProtoMessage() {} - -func (x *HistoryResponse) ProtoReflect() protoreflect.Message { - mi := &file_waku_store_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 HistoryResponse.ProtoReflect.Descriptor instead. +func (m *HistoryResponse) Reset() { *m = HistoryResponse{} } +func (m *HistoryResponse) String() string { return proto.CompactTextString(m) } +func (*HistoryResponse) ProtoMessage() {} func (*HistoryResponse) Descriptor() ([]byte, []int) { - return file_waku_store_proto_rawDescGZIP(), []int{3} + return fileDescriptor_ca6891f77a46e680, []int{3} +} +func (m *HistoryResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *HistoryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_HistoryResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *HistoryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_HistoryResponse.Merge(m, src) +} +func (m *HistoryResponse) XXX_Size() int { + return m.Size() +} +func (m *HistoryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_HistoryResponse.DiscardUnknown(m) } -func (x *HistoryResponse) GetMessages() []*WakuMessage { - if x != nil { - return x.Messages +var xxx_messageInfo_HistoryResponse proto.InternalMessageInfo + +func (m *HistoryResponse) GetMessages() []*WakuMessage { + if m != nil { + return m.Messages } return nil } -func (x *HistoryResponse) GetPagingInfo() *PagingInfo { - if x != nil { - return x.PagingInfo +func (m *HistoryResponse) GetPagingInfo() *PagingInfo { + if m != nil { + return m.PagingInfo } return nil } type HistoryRPC struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` - Query *HistoryQuery `protobuf:"bytes,2,opt,name=query,proto3" json:"query,omitempty"` - Response *HistoryResponse `protobuf:"bytes,3,opt,name=response,proto3" json:"response,omitempty"` + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + Query *HistoryQuery `protobuf:"bytes,2,opt,name=query,proto3" json:"query,omitempty"` + Response *HistoryResponse `protobuf:"bytes,3,opt,name=response,proto3" json:"response,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x *HistoryRPC) Reset() { - *x = HistoryRPC{} - if protoimpl.UnsafeEnabled { - mi := &file_waku_store_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HistoryRPC) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HistoryRPC) ProtoMessage() {} - -func (x *HistoryRPC) ProtoReflect() protoreflect.Message { - mi := &file_waku_store_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 HistoryRPC.ProtoReflect.Descriptor instead. +func (m *HistoryRPC) Reset() { *m = HistoryRPC{} } +func (m *HistoryRPC) String() string { return proto.CompactTextString(m) } +func (*HistoryRPC) ProtoMessage() {} func (*HistoryRPC) Descriptor() ([]byte, []int) { - return file_waku_store_proto_rawDescGZIP(), []int{4} + return fileDescriptor_ca6891f77a46e680, []int{4} +} +func (m *HistoryRPC) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *HistoryRPC) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_HistoryRPC.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *HistoryRPC) XXX_Merge(src proto.Message) { + xxx_messageInfo_HistoryRPC.Merge(m, src) +} +func (m *HistoryRPC) XXX_Size() int { + return m.Size() +} +func (m *HistoryRPC) XXX_DiscardUnknown() { + xxx_messageInfo_HistoryRPC.DiscardUnknown(m) } -func (x *HistoryRPC) GetRequestId() string { - if x != nil { - return x.RequestId +var xxx_messageInfo_HistoryRPC proto.InternalMessageInfo + +func (m *HistoryRPC) GetRequestId() string { + if m != nil { + return m.RequestId } return "" } -func (x *HistoryRPC) GetQuery() *HistoryQuery { - if x != nil { - return x.Query +func (m *HistoryRPC) GetQuery() *HistoryQuery { + if m != nil { + return m.Query } return nil } -func (x *HistoryRPC) GetResponse() *HistoryResponse { - if x != nil { - return x.Response +func (m *HistoryRPC) GetResponse() *HistoryResponse { + if m != nil { + return m.Response } return nil } -var File_waku_store_proto protoreflect.FileDescriptor +func init() { + proto.RegisterEnum("protocol.PagingInfo_Direction", PagingInfo_Direction_name, PagingInfo_Direction_value) + proto.RegisterType((*Index)(nil), "protocol.Index") + proto.RegisterType((*PagingInfo)(nil), "protocol.PagingInfo") + proto.RegisterType((*HistoryQuery)(nil), "protocol.HistoryQuery") + proto.RegisterType((*HistoryResponse)(nil), "protocol.HistoryResponse") + proto.RegisterType((*HistoryRPC)(nil), "protocol.HistoryRPC") +} -var file_waku_store_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x77, 0x61, 0x6b, 0x75, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x1a, 0x12, 0x77, 0x61, - 0x6b, 0x75, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x43, 0x0a, 0x05, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x69, 0x67, - 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, - 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x54, 0x69, 0x6d, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0c, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, - 0x64, 0x54, 0x69, 0x6d, 0x65, 0x22, 0xb7, 0x01, 0x0a, 0x0a, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x67, - 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, - 0x12, 0x27, 0x0a, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x49, 0x6e, 0x64, 0x65, - 0x78, 0x52, 0x06, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x12, 0x3c, 0x0a, 0x09, 0x64, 0x69, 0x72, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x49, 0x6e, - 0x66, 0x6f, 0x2e, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x64, 0x69, - 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x26, 0x0a, 0x09, 0x44, 0x69, 0x72, 0x65, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, 0x46, 0x4f, 0x52, 0x57, 0x41, 0x52, 0x44, 0x10, - 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x42, 0x41, 0x43, 0x4b, 0x57, 0x41, 0x52, 0x44, 0x10, 0x01, 0x22, - 0x70, 0x0a, 0x0c, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, - 0x16, 0x0a, 0x06, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0d, 0x52, - 0x06, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x73, 0x12, 0x39, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, - 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, - 0x6f, 0x48, 0x00, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x88, - 0x01, 0x01, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, - 0x6f, 0x22, 0x8e, 0x01, 0x0a, 0x0f, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x31, 0x0a, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, - 0x6f, 0x6c, 0x2e, 0x57, 0x61, 0x6b, 0x75, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x08, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, 0x39, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, - 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x49, 0x6e, - 0x66, 0x6f, 0x48, 0x00, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, - 0x88, 0x01, 0x01, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x49, 0x6e, - 0x66, 0x6f, 0x22, 0x90, 0x01, 0x0a, 0x0a, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x50, - 0x43, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, - 0x12, 0x2c, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x48, 0x69, 0x73, 0x74, 0x6f, - 0x72, 0x79, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x35, - 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x48, 0x69, 0x73, 0x74, - 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +func init() { proto.RegisterFile("waku_store.proto", fileDescriptor_ca6891f77a46e680) } + +var fileDescriptor_ca6891f77a46e680 = []byte{ + // 427 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x51, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0xed, 0x92, 0x36, 0xb5, 0x27, 0x81, 0x46, 0x23, 0xa8, 0x4c, 0x05, 0x56, 0xe4, 0x03, 0xe4, + 0x80, 0x2c, 0x61, 0xe0, 0xc6, 0xa5, 0x4d, 0x85, 0x88, 0x10, 0xa2, 0x2c, 0x48, 0x3d, 0x56, 0xc6, + 0x1e, 0xac, 0x55, 0xa9, 0xd7, 0xdd, 0x5d, 0x03, 0xed, 0x57, 0x70, 0xe0, 0xc0, 0x9f, 0xf0, 0x0b, + 0x1c, 0xf9, 0x04, 0x14, 0x7e, 0x04, 0x65, 0xbd, 0xb6, 0x83, 0xe0, 0xd4, 0xd3, 0xea, 0xcd, 0x7b, + 0x33, 0xf3, 0xf6, 0x0d, 0x4c, 0x3e, 0xa5, 0xa7, 0xf5, 0x89, 0x36, 0x52, 0x51, 0x5c, 0x29, 0x69, + 0x24, 0x7a, 0xf6, 0xc9, 0xe4, 0x87, 0x3d, 0xb4, 0xdc, 0x19, 0x69, 0x9d, 0x16, 0x8e, 0x8d, 0xe6, + 0xb0, 0xb5, 0x28, 0x73, 0xfa, 0x8c, 0xbb, 0x30, 0xcc, 0x45, 0x41, 0xda, 0x04, 0x6c, 0xca, 0x66, + 0x63, 0xee, 0x10, 0x46, 0x30, 0x56, 0x94, 0x91, 0xf8, 0x48, 0xf9, 0x5b, 0x71, 0x46, 0xc1, 0xb5, + 0x29, 0x9b, 0x31, 0xfe, 0x57, 0x2d, 0xfa, 0xce, 0x00, 0x8e, 0xd2, 0x42, 0x94, 0xc5, 0xa2, 0x7c, + 0x2f, 0x71, 0x0f, 0xbc, 0x2a, 0x2d, 0xe8, 0x8d, 0xb8, 0x24, 0x3b, 0x6c, 0x93, 0x77, 0x18, 0xef, + 0xc3, 0x30, 0xab, 0x95, 0x96, 0xca, 0x0e, 0x1a, 0x25, 0x3b, 0x71, 0x6b, 0x2f, 0xb6, 0x3e, 0xb8, + 0xa3, 0xf1, 0x29, 0xf8, 0xb9, 0x50, 0x94, 0x19, 0x21, 0xcb, 0x60, 0x30, 0x65, 0xb3, 0x1b, 0x49, + 0xd8, 0x6b, 0xfb, 0x6d, 0xf1, 0x61, 0xab, 0xe2, 0x7d, 0x43, 0x74, 0x0f, 0xfc, 0xae, 0x8e, 0x63, + 0xf0, 0x0e, 0xf6, 0xe7, 0x2f, 0x8e, 0xf7, 0xf9, 0xe1, 0x64, 0x03, 0x47, 0xb0, 0xfd, 0xec, 0x15, + 0xb7, 0x80, 0x45, 0x5f, 0x19, 0x8c, 0x9f, 0x8b, 0x55, 0x5c, 0x17, 0xaf, 0x6b, 0x52, 0x17, 0xab, + 0x18, 0x8c, 0xac, 0x44, 0xa6, 0x03, 0x36, 0x1d, 0xcc, 0xae, 0x73, 0x87, 0xf0, 0x31, 0x40, 0xd5, + 0xed, 0x74, 0xde, 0x6f, 0xfe, 0xcf, 0x0f, 0x5f, 0xd3, 0xe1, 0x1d, 0xf0, 0xb5, 0x49, 0x95, 0xb1, + 0xc9, 0x0d, 0x6c, 0x72, 0x7d, 0x01, 0x03, 0xd8, 0xa6, 0xb2, 0x49, 0x75, 0xd3, 0x72, 0x2d, 0x8c, + 0x2e, 0x61, 0xc7, 0xb9, 0xe2, 0xa4, 0x2b, 0x59, 0x6a, 0xc2, 0x87, 0xe0, 0xb9, 0xcb, 0x35, 0xd6, + 0x46, 0xc9, 0xad, 0x7e, 0xfd, 0x71, 0x7a, 0x5a, 0xbf, 0x6c, 0x58, 0xde, 0xc9, 0xae, 0xe6, 0x39, + 0xfa, 0xc2, 0x00, 0xda, 0xe5, 0x47, 0x73, 0xbc, 0x0b, 0xa0, 0xe8, 0xbc, 0x26, 0x6d, 0x4e, 0x44, + 0x6e, 0xcf, 0xe9, 0x73, 0xdf, 0x55, 0x16, 0x39, 0x3e, 0x80, 0xad, 0xf3, 0x55, 0x70, 0x6e, 0xfc, + 0x6e, 0x3f, 0x7e, 0x3d, 0x56, 0xde, 0x88, 0xf0, 0x09, 0x78, 0xca, 0x7d, 0xc8, 0xc6, 0x31, 0x4a, + 0x6e, 0xff, 0xd3, 0xd0, 0xfe, 0x98, 0x77, 0xd2, 0x83, 0xc9, 0x8f, 0x65, 0xc8, 0x7e, 0x2e, 0x43, + 0xf6, 0x6b, 0x19, 0xb2, 0x6f, 0xbf, 0xc3, 0x8d, 0x77, 0x43, 0xdb, 0xf5, 0xe8, 0x4f, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x7e, 0xa9, 0x5e, 0x0d, 0xef, 0x02, 0x00, 0x00, +} + +func (m *Index) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Index) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Index) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.ReceivedTime != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.ReceivedTime)))) + i-- + dAtA[i] = 0x11 + } + if len(m.Digest) > 0 { + i -= len(m.Digest) + copy(dAtA[i:], m.Digest) + i = encodeVarintWakuStore(dAtA, i, uint64(len(m.Digest))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PagingInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PagingInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PagingInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Direction != 0 { + i = encodeVarintWakuStore(dAtA, i, uint64(m.Direction)) + i-- + dAtA[i] = 0x18 + } + if m.Cursor != nil { + { + size, err := m.Cursor.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintWakuStore(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.PageSize != 0 { + i = encodeVarintWakuStore(dAtA, i, uint64(m.PageSize)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *HistoryQuery) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *HistoryQuery) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *HistoryQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.EndTime != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.EndTime)))) + i-- + dAtA[i] = 0x21 + } + if m.StartTime != 0 { + i -= 8 + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.StartTime)))) + i-- + dAtA[i] = 0x19 + } + if m.PagingInfo != nil { + { + size, err := m.PagingInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintWakuStore(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Topics) > 0 { + dAtA4 := make([]byte, len(m.Topics)*10) + var j3 int + for _, num := range m.Topics { + for num >= 1<<7 { + dAtA4[j3] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j3++ + } + dAtA4[j3] = uint8(num) + j3++ + } + i -= j3 + copy(dAtA[i:], dAtA4[:j3]) + i = encodeVarintWakuStore(dAtA, i, uint64(j3)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *HistoryResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *HistoryResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *HistoryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.PagingInfo != nil { + { + size, err := m.PagingInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintWakuStore(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Messages) > 0 { + for iNdEx := len(m.Messages) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Messages[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintWakuStore(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *HistoryRPC) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *HistoryRPC) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *HistoryRPC) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Response != nil { + { + size, err := m.Response.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintWakuStore(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.Query != nil { + { + size, err := m.Query.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintWakuStore(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.RequestId) > 0 { + i -= len(m.RequestId) + copy(dAtA[i:], m.RequestId) + i = encodeVarintWakuStore(dAtA, i, uint64(len(m.RequestId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintWakuStore(dAtA []byte, offset int, v uint64) int { + offset -= sovWakuStore(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Index) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Digest) + if l > 0 { + n += 1 + l + sovWakuStore(uint64(l)) + } + if m.ReceivedTime != 0 { + n += 9 + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *PagingInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PageSize != 0 { + n += 1 + sovWakuStore(uint64(m.PageSize)) + } + if m.Cursor != nil { + l = m.Cursor.Size() + n += 1 + l + sovWakuStore(uint64(l)) + } + if m.Direction != 0 { + n += 1 + sovWakuStore(uint64(m.Direction)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *HistoryQuery) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Topics) > 0 { + l = 0 + for _, e := range m.Topics { + l += sovWakuStore(uint64(e)) + } + n += 1 + sovWakuStore(uint64(l)) + l + } + if m.PagingInfo != nil { + l = m.PagingInfo.Size() + n += 1 + l + sovWakuStore(uint64(l)) + } + if m.StartTime != 0 { + n += 9 + } + if m.EndTime != 0 { + n += 9 + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *HistoryResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Messages) > 0 { + for _, e := range m.Messages { + l = e.Size() + n += 1 + l + sovWakuStore(uint64(l)) + } + } + if m.PagingInfo != nil { + l = m.PagingInfo.Size() + n += 1 + l + sovWakuStore(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *HistoryRPC) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RequestId) + if l > 0 { + n += 1 + l + sovWakuStore(uint64(l)) + } + if m.Query != nil { + l = m.Query.Size() + n += 1 + l + sovWakuStore(uint64(l)) + } + if m.Response != nil { + l = m.Response.Size() + n += 1 + l + sovWakuStore(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovWakuStore(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozWakuStore(x uint64) (n int) { + return sovWakuStore(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Index) Unmarshal(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 ErrIntOverflowWakuStore + } + 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: Index: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Index: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Digest", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuStore + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthWakuStore + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthWakuStore + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Digest = append(m.Digest[:0], dAtA[iNdEx:postIndex]...) + if m.Digest == nil { + m.Digest = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field ReceivedTime", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.ReceivedTime = float64(math.Float64frombits(v)) + default: + iNdEx = preIndex + skippy, err := skipWakuStore(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthWakuStore + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PagingInfo) Unmarshal(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 ErrIntOverflowWakuStore + } + 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: PagingInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PagingInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PageSize", wireType) + } + m.PageSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuStore + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PageSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Cursor", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuStore + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthWakuStore + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthWakuStore + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Cursor == nil { + m.Cursor = &Index{} + } + if err := m.Cursor.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Direction", wireType) + } + m.Direction = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuStore + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Direction |= PagingInfo_Direction(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipWakuStore(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthWakuStore + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *HistoryQuery) Unmarshal(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 ErrIntOverflowWakuStore + } + 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: HistoryQuery: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: HistoryQuery: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuStore + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Topics = append(m.Topics, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuStore + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthWakuStore + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthWakuStore + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Topics) == 0 { + m.Topics = make([]uint32, 0, elementCount) + } + for iNdEx < postIndex { + var v uint32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuStore + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Topics = append(m.Topics, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Topics", wireType) + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PagingInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuStore + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthWakuStore + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthWakuStore + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PagingInfo == nil { + m.PagingInfo = &PagingInfo{} + } + if err := m.PagingInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.StartTime = float64(math.Float64frombits(v)) + case 4: + if wireType != 1 { + return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return io.ErrUnexpectedEOF + } + v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + m.EndTime = float64(math.Float64frombits(v)) + default: + iNdEx = preIndex + skippy, err := skipWakuStore(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthWakuStore + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *HistoryResponse) Unmarshal(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 ErrIntOverflowWakuStore + } + 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: HistoryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: HistoryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Messages", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuStore + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthWakuStore + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthWakuStore + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Messages = append(m.Messages, &WakuMessage{}) + if err := m.Messages[len(m.Messages)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PagingInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuStore + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthWakuStore + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthWakuStore + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PagingInfo == nil { + m.PagingInfo = &PagingInfo{} + } + if err := m.PagingInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipWakuStore(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthWakuStore + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *HistoryRPC) Unmarshal(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 ErrIntOverflowWakuStore + } + 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: HistoryRPC: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: HistoryRPC: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuStore + } + 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 ErrInvalidLengthWakuStore + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthWakuStore + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RequestId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Query", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuStore + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthWakuStore + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthWakuStore + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Query == nil { + m.Query = &HistoryQuery{} + } + if err := m.Query.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Response", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWakuStore + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthWakuStore + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthWakuStore + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Response == nil { + m.Response = &HistoryResponse{} + } + if err := m.Response.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipWakuStore(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthWakuStore + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipWakuStore(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowWakuStore + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowWakuStore + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowWakuStore + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthWakuStore + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupWakuStore + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthWakuStore + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF } var ( - file_waku_store_proto_rawDescOnce sync.Once - file_waku_store_proto_rawDescData = file_waku_store_proto_rawDesc + ErrInvalidLengthWakuStore = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowWakuStore = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupWakuStore = fmt.Errorf("proto: unexpected end of group") ) - -func file_waku_store_proto_rawDescGZIP() []byte { - file_waku_store_proto_rawDescOnce.Do(func() { - file_waku_store_proto_rawDescData = protoimpl.X.CompressGZIP(file_waku_store_proto_rawDescData) - }) - return file_waku_store_proto_rawDescData -} - -var file_waku_store_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_waku_store_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_waku_store_proto_goTypes = []interface{}{ - (PagingInfo_Direction)(0), // 0: protocol.PagingInfo.Direction - (*Index)(nil), // 1: protocol.Index - (*PagingInfo)(nil), // 2: protocol.PagingInfo - (*HistoryQuery)(nil), // 3: protocol.HistoryQuery - (*HistoryResponse)(nil), // 4: protocol.HistoryResponse - (*HistoryRPC)(nil), // 5: protocol.HistoryRPC - (*WakuMessage)(nil), // 6: protocol.WakuMessage -} -var file_waku_store_proto_depIdxs = []int32{ - 1, // 0: protocol.PagingInfo.cursor:type_name -> protocol.Index - 0, // 1: protocol.PagingInfo.direction:type_name -> protocol.PagingInfo.Direction - 2, // 2: protocol.HistoryQuery.pagingInfo:type_name -> protocol.PagingInfo - 6, // 3: protocol.HistoryResponse.messages:type_name -> protocol.WakuMessage - 2, // 4: protocol.HistoryResponse.pagingInfo:type_name -> protocol.PagingInfo - 3, // 5: protocol.HistoryRPC.query:type_name -> protocol.HistoryQuery - 4, // 6: protocol.HistoryRPC.response:type_name -> protocol.HistoryResponse - 7, // [7:7] is the sub-list for method output_type - 7, // [7:7] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name -} - -func init() { file_waku_store_proto_init() } -func file_waku_store_proto_init() { - if File_waku_store_proto != nil { - return - } - file_waku_message_proto_init() - if !protoimpl.UnsafeEnabled { - file_waku_store_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Index); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_waku_store_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PagingInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_waku_store_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HistoryQuery); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_waku_store_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HistoryResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_waku_store_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HistoryRPC); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_waku_store_proto_msgTypes[2].OneofWrappers = []interface{}{} - file_waku_store_proto_msgTypes[3].OneofWrappers = []interface{}{} - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_waku_store_proto_rawDesc, - NumEnums: 1, - NumMessages: 5, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_waku_store_proto_goTypes, - DependencyIndexes: file_waku_store_proto_depIdxs, - EnumInfos: file_waku_store_proto_enumTypes, - MessageInfos: file_waku_store_proto_msgTypes, - }.Build() - File_waku_store_proto = out.File - file_waku_store_proto_rawDesc = nil - file_waku_store_proto_goTypes = nil - file_waku_store_proto_depIdxs = nil -} diff --git a/waku/v2/protocol/waku_store.proto b/waku/v2/protocol/waku_store.proto index 280d5502..0dbeec18 100644 --- a/waku/v2/protocol/waku_store.proto +++ b/waku/v2/protocol/waku_store.proto @@ -10,27 +10,29 @@ message Index { } message PagingInfo { - int64 pageSize = 1; + uint64 pageSize = 1; Index cursor = 2; enum Direction { - FORWARD = 0; - BACKWARD = 1; + BACKWARD = 0; + FORWARD = 1; } Direction direction = 3; } message HistoryQuery { repeated uint32 topics = 1; - optional PagingInfo pagingInfo = 2; // used for pagination + PagingInfo pagingInfo = 2; // used for pagination + double startTime = 3; + double endTime = 4; } message HistoryResponse { repeated WakuMessage messages = 1; - optional PagingInfo pagingInfo = 2; // used for pagination + PagingInfo pagingInfo = 2; // used for pagination } message HistoryRPC { string request_id = 1; HistoryQuery query = 2; HistoryResponse response = 3; -} \ No newline at end of file +} diff --git a/waku/v2/protocol/waku_store/waku_store.go b/waku/v2/protocol/waku_store/waku_store.go index 977c691a..ca1f8abb 100644 --- a/waku/v2/protocol/waku_store/waku_store.go +++ b/waku/v2/protocol/waku_store/waku_store.go @@ -8,7 +8,6 @@ import ( "encoding/hex" "errors" "fmt" - "io/ioutil" "sort" "sync" "time" @@ -20,11 +19,11 @@ import ( "github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peerstore" libp2pProtocol "github.com/libp2p/go-libp2p-core/protocol" + "github.com/libp2p/go-msgio/protoio" ma "github.com/multiformats/go-multiaddr" "github.com/status-im/go-waku/waku/common" "github.com/status-im/go-waku/waku/v2/protocol" - "google.golang.org/protobuf/proto" ) var log = logging.Logger("wakustore") @@ -118,7 +117,7 @@ func paginateWithIndex(list []IndexedWakuMessage, pinfo *protocol.PagingInfo) (r for i := s; i <= e; i++ { resMessages = append(resMessages, msgList[i]) } - resPagingInfo = &protocol.PagingInfo{PageSize: int64(retrievedPageSize), Cursor: newCursor, Direction: pinfo.Direction} + resPagingInfo = &protocol.PagingInfo{PageSize: uint64(retrievedPageSize), Cursor: newCursor, Direction: pinfo.Direction} return } @@ -148,7 +147,7 @@ func (w *WakuStore) FindMessages(query *protocol.HistoryQuery) *protocol.History // data holds IndexedWakuMessage whose topics match the query var data []IndexedWakuMessage for _, indexedMsg := range w.messages { - if contains(query.Topics, *indexedMsg.msg.ContentTopic) { + if contains(query.Topics, indexedMsg.msg.ContentTopic) { data = append(data, indexedMsg) } } @@ -188,6 +187,10 @@ func NewWakuStore(ctx context.Context, h host.Host, msg chan *common.Envelope, p } func (store *WakuStore) Start() { + if store.msgProvider == nil { + return + } + store.h.SetStreamHandler(WakuStoreProtocolId, store.onRequest) messages, err := store.msgProvider.GetAll() @@ -237,34 +240,22 @@ func (store *WakuStore) onRequest(s network.Stream) { historyRPCRequest := &protocol.HistoryRPC{} - buf := make([]byte, 64*1024) - _, err := s.Read(buf) + writer := protoio.NewDelimitedWriter(s) + reader := protoio.NewDelimitedReader(s, 64*1024) + err := reader.ReadMsg(historyRPCRequest) if err != nil { - s.Reset() log.Error("error reading request", err) return } - proto.Unmarshal(buf, historyRPCRequest) - if err != nil { - log.Error("error decoding request", err) - return - } - log.Info(fmt.Sprintf("%s: Received query from %s", s.Conn().LocalPeer(), s.Conn().RemotePeer())) historyResponseRPC := &protocol.HistoryRPC{} historyResponseRPC.RequestId = historyRPCRequest.RequestId historyResponseRPC.Response = store.FindMessages(historyRPCRequest.Query) - message, err := proto.Marshal(historyResponseRPC) - if err != nil { - log.Error("error encoding response", err) - return - } - - _, err = s.Write(message) + err = writer.WriteMsg(historyResponseRPC) if err != nil { log.Error("error writing response", err) s.Reset() @@ -274,7 +265,7 @@ func (store *WakuStore) onRequest(s network.Stream) { } func computeIndex(msg *protocol.WakuMessage) (*protocol.Index, error) { - data, err := proto.Marshal(msg) + data, err := msg.Marshal() if err != nil { return nil, err } @@ -415,36 +406,27 @@ func (store *WakuStore) Query(q *protocol.HistoryQuery) (*protocol.HistoryRespon return nil, err } - historyRequest := &protocol.HistoryRPC{Query: q, RequestId: GenerateRequestId()} - - message, err := proto.Marshal(historyRequest) - if err != nil { - log.Error("could not encode request", err) - return nil, err - } - defer connOpt.Close() defer connOpt.Reset() - _, err = connOpt.Write(message) + historyRequest := &protocol.HistoryRPC{Query: q, RequestId: GenerateRequestId()} + + writer := protoio.NewDelimitedWriter(connOpt) + reader := protoio.NewDelimitedReader(connOpt, 64*1024) + + err = writer.WriteMsg(historyRequest) if err != nil { log.Error("could not write request", err) return nil, err } - buf, err := ioutil.ReadAll(connOpt) + historyResponseRPC := &protocol.HistoryRPC{} + err = reader.ReadMsg(historyResponseRPC) if err != nil { log.Error("could not read response", err) return nil, err } - historyResponseRPC := &protocol.HistoryRPC{} - proto.Unmarshal(buf, historyResponseRPC) - if err != nil { - log.Error("could not decode response", err) - return nil, err - } - return historyResponseRPC.Response, nil }