mirror of https://github.com/status-im/go-waku.git
add history content filter
This commit is contained in:
parent
e539439f16
commit
287a54aca7
|
@ -201,7 +201,11 @@ func (w *WakuNode) Query(contentTopics []string, startTime float64, endTime floa
|
||||||
}
|
}
|
||||||
|
|
||||||
query := new(protocol.HistoryQuery)
|
query := new(protocol.HistoryQuery)
|
||||||
query.Topics = contentTopics
|
|
||||||
|
for _, ct := range contentTopics {
|
||||||
|
query.ContentFilters = append(query.ContentFilters, &protocol.ContentFilter{ContentTopic: ct})
|
||||||
|
}
|
||||||
|
|
||||||
query.StartTime = startTime
|
query.StartTime = startTime
|
||||||
query.EndTime = endTime
|
query.EndTime = endTime
|
||||||
query.PagingInfo = new(protocol.PagingInfo)
|
query.PagingInfo = new(protocol.PagingInfo)
|
||||||
|
|
|
@ -166,21 +166,68 @@ func (m *PagingInfo) GetDirection() PagingInfo_Direction {
|
||||||
return PagingInfo_BACKWARD
|
return PagingInfo_BACKWARD
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ContentFilter struct {
|
||||||
|
ContentTopic string `protobuf:"bytes,1,opt,name=contentTopic,proto3" json:"contentTopic,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ContentFilter) Reset() { *m = ContentFilter{} }
|
||||||
|
func (m *ContentFilter) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*ContentFilter) ProtoMessage() {}
|
||||||
|
func (*ContentFilter) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_ca6891f77a46e680, []int{2}
|
||||||
|
}
|
||||||
|
func (m *ContentFilter) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *ContentFilter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_ContentFilter.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 *ContentFilter) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_ContentFilter.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *ContentFilter) XXX_Size() int {
|
||||||
|
return m.Size()
|
||||||
|
}
|
||||||
|
func (m *ContentFilter) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_ContentFilter.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_ContentFilter proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *ContentFilter) GetContentTopic() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.ContentTopic
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
type HistoryQuery struct {
|
type HistoryQuery struct {
|
||||||
Topics []string `protobuf:"bytes,1,rep,name=topics,proto3" json:"topics,omitempty"`
|
ContentFilters []*ContentFilter `protobuf:"bytes,2,rep,name=contentFilters,proto3" json:"contentFilters,omitempty"`
|
||||||
PagingInfo *PagingInfo `protobuf:"bytes,2,opt,name=pagingInfo,proto3" json:"pagingInfo,omitempty"`
|
PagingInfo *PagingInfo `protobuf:"bytes,3,opt,name=pagingInfo,proto3" json:"pagingInfo,omitempty"`
|
||||||
StartTime float64 `protobuf:"fixed64,3,opt,name=startTime,proto3" json:"startTime,omitempty"`
|
StartTime float64 `protobuf:"fixed64,4,opt,name=startTime,proto3" json:"startTime,omitempty"`
|
||||||
EndTime float64 `protobuf:"fixed64,4,opt,name=endTime,proto3" json:"endTime,omitempty"`
|
EndTime float64 `protobuf:"fixed64,5,opt,name=endTime,proto3" json:"endTime,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_unrecognized []byte `json:"-"`
|
||||||
XXX_sizecache int32 `json:"-"`
|
XXX_sizecache int32 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *HistoryQuery) Reset() { *m = HistoryQuery{} }
|
func (m *HistoryQuery) Reset() { *m = HistoryQuery{} }
|
||||||
func (m *HistoryQuery) String() string { return proto.CompactTextString(m) }
|
func (m *HistoryQuery) String() string { return proto.CompactTextString(m) }
|
||||||
func (*HistoryQuery) ProtoMessage() {}
|
func (*HistoryQuery) ProtoMessage() {}
|
||||||
func (*HistoryQuery) Descriptor() ([]byte, []int) {
|
func (*HistoryQuery) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_ca6891f77a46e680, []int{2}
|
return fileDescriptor_ca6891f77a46e680, []int{3}
|
||||||
}
|
}
|
||||||
func (m *HistoryQuery) XXX_Unmarshal(b []byte) error {
|
func (m *HistoryQuery) XXX_Unmarshal(b []byte) error {
|
||||||
return m.Unmarshal(b)
|
return m.Unmarshal(b)
|
||||||
|
@ -209,9 +256,9 @@ func (m *HistoryQuery) XXX_DiscardUnknown() {
|
||||||
|
|
||||||
var xxx_messageInfo_HistoryQuery proto.InternalMessageInfo
|
var xxx_messageInfo_HistoryQuery proto.InternalMessageInfo
|
||||||
|
|
||||||
func (m *HistoryQuery) GetTopics() []string {
|
func (m *HistoryQuery) GetContentFilters() []*ContentFilter {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Topics
|
return m.ContentFilters
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -249,7 +296,7 @@ func (m *HistoryResponse) Reset() { *m = HistoryResponse{} }
|
||||||
func (m *HistoryResponse) String() string { return proto.CompactTextString(m) }
|
func (m *HistoryResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*HistoryResponse) ProtoMessage() {}
|
func (*HistoryResponse) ProtoMessage() {}
|
||||||
func (*HistoryResponse) Descriptor() ([]byte, []int) {
|
func (*HistoryResponse) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_ca6891f77a46e680, []int{3}
|
return fileDescriptor_ca6891f77a46e680, []int{4}
|
||||||
}
|
}
|
||||||
func (m *HistoryResponse) XXX_Unmarshal(b []byte) error {
|
func (m *HistoryResponse) XXX_Unmarshal(b []byte) error {
|
||||||
return m.Unmarshal(b)
|
return m.Unmarshal(b)
|
||||||
|
@ -305,7 +352,7 @@ func (m *HistoryRPC) Reset() { *m = HistoryRPC{} }
|
||||||
func (m *HistoryRPC) String() string { return proto.CompactTextString(m) }
|
func (m *HistoryRPC) String() string { return proto.CompactTextString(m) }
|
||||||
func (*HistoryRPC) ProtoMessage() {}
|
func (*HistoryRPC) ProtoMessage() {}
|
||||||
func (*HistoryRPC) Descriptor() ([]byte, []int) {
|
func (*HistoryRPC) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_ca6891f77a46e680, []int{4}
|
return fileDescriptor_ca6891f77a46e680, []int{5}
|
||||||
}
|
}
|
||||||
func (m *HistoryRPC) XXX_Unmarshal(b []byte) error {
|
func (m *HistoryRPC) XXX_Unmarshal(b []byte) error {
|
||||||
return m.Unmarshal(b)
|
return m.Unmarshal(b)
|
||||||
|
@ -359,6 +406,7 @@ func init() {
|
||||||
proto.RegisterEnum("protocol.PagingInfo_Direction", PagingInfo_Direction_name, PagingInfo_Direction_value)
|
proto.RegisterEnum("protocol.PagingInfo_Direction", PagingInfo_Direction_name, PagingInfo_Direction_value)
|
||||||
proto.RegisterType((*Index)(nil), "protocol.Index")
|
proto.RegisterType((*Index)(nil), "protocol.Index")
|
||||||
proto.RegisterType((*PagingInfo)(nil), "protocol.PagingInfo")
|
proto.RegisterType((*PagingInfo)(nil), "protocol.PagingInfo")
|
||||||
|
proto.RegisterType((*ContentFilter)(nil), "protocol.ContentFilter")
|
||||||
proto.RegisterType((*HistoryQuery)(nil), "protocol.HistoryQuery")
|
proto.RegisterType((*HistoryQuery)(nil), "protocol.HistoryQuery")
|
||||||
proto.RegisterType((*HistoryResponse)(nil), "protocol.HistoryResponse")
|
proto.RegisterType((*HistoryResponse)(nil), "protocol.HistoryResponse")
|
||||||
proto.RegisterType((*HistoryRPC)(nil), "protocol.HistoryRPC")
|
proto.RegisterType((*HistoryRPC)(nil), "protocol.HistoryRPC")
|
||||||
|
@ -367,34 +415,36 @@ func init() {
|
||||||
func init() { proto.RegisterFile("waku_store.proto", fileDescriptor_ca6891f77a46e680) }
|
func init() { proto.RegisterFile("waku_store.proto", fileDescriptor_ca6891f77a46e680) }
|
||||||
|
|
||||||
var fileDescriptor_ca6891f77a46e680 = []byte{
|
var fileDescriptor_ca6891f77a46e680 = []byte{
|
||||||
// 426 bytes of a gzipped FileDescriptorProto
|
// 464 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x51, 0xc1, 0x6e, 0xd4, 0x30,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xc1, 0x6e, 0xd3, 0x40,
|
||||||
0x10, 0xad, 0xd9, 0x76, 0x9b, 0xcc, 0xae, 0xe8, 0x6a, 0x04, 0x55, 0xa8, 0x20, 0x5a, 0xe5, 0x00,
|
0x10, 0xed, 0xb6, 0x4d, 0x6a, 0x4f, 0x42, 0x1b, 0x8d, 0xa0, 0x98, 0x0a, 0xac, 0xc8, 0x07, 0xc8,
|
||||||
0x39, 0xa0, 0x48, 0x04, 0xb8, 0x71, 0x69, 0xb7, 0x42, 0xac, 0x10, 0xa2, 0x18, 0xa4, 0x1e, 0xab,
|
0x01, 0x45, 0x22, 0x85, 0x1b, 0x12, 0x6a, 0x53, 0x55, 0x44, 0x08, 0x51, 0x96, 0x4a, 0x3d, 0x56,
|
||||||
0x90, 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9f, 0xab, 0x90, 0x7d, 0xfd, 0x15, 0x6e, 0xbc, 0x1d, 0xdb, 0xae, 0x87, 0xbf, 0x03, 0x00, 0x00,
|
0x31, 0xb4, 0x2e, 0x67, 0x09, 0xbb, 0xf1, 0xdb, 0xcd, 0xf8, 0xc5, 0xfc, 0xf9, 0x9c, 0x84, 0xcf,
|
||||||
0xff, 0xff, 0x9f, 0x85, 0xef, 0xfb, 0xef, 0x02, 0x00, 0x00,
|
0xc0, 0x53, 0xce, 0x90, 0xcb, 0xf0, 0xde, 0x5f, 0x0f, 0x2a, 0xc7, 0xbc, 0xa6, 0xee, 0xf7, 0x7e,
|
||||||
|
0x4c, 0x43, 0xf6, 0x73, 0x1a, 0xb2, 0x5f, 0xd3, 0x90, 0x7d, 0xfd, 0x1d, 0xae, 0xbc, 0x6f, 0xdb,
|
||||||
|
0x57, 0xbb, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xb5, 0xbb, 0x7a, 0xf0, 0x4d, 0x03, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Index) Marshal() (dAtA []byte, err error) {
|
func (m *Index) Marshal() (dAtA []byte, err error) {
|
||||||
|
@ -486,6 +536,40 @@ func (m *PagingInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
return len(dAtA) - i, nil
|
return len(dAtA) - i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *ContentFilter) 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 *ContentFilter) MarshalTo(dAtA []byte) (int, error) {
|
||||||
|
size := m.Size()
|
||||||
|
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ContentFilter) 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 len(m.ContentTopic) > 0 {
|
||||||
|
i -= len(m.ContentTopic)
|
||||||
|
copy(dAtA[i:], m.ContentTopic)
|
||||||
|
i = encodeVarintWakuStore(dAtA, i, uint64(len(m.ContentTopic)))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0xa
|
||||||
|
}
|
||||||
|
return len(dAtA) - i, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m *HistoryQuery) Marshal() (dAtA []byte, err error) {
|
func (m *HistoryQuery) Marshal() (dAtA []byte, err error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
dAtA = make([]byte, size)
|
dAtA = make([]byte, size)
|
||||||
|
@ -514,13 +598,13 @@ func (m *HistoryQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
i -= 8
|
i -= 8
|
||||||
encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.EndTime))))
|
encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.EndTime))))
|
||||||
i--
|
i--
|
||||||
dAtA[i] = 0x21
|
dAtA[i] = 0x29
|
||||||
}
|
}
|
||||||
if m.StartTime != 0 {
|
if m.StartTime != 0 {
|
||||||
i -= 8
|
i -= 8
|
||||||
encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.StartTime))))
|
encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.StartTime))))
|
||||||
i--
|
i--
|
||||||
dAtA[i] = 0x19
|
dAtA[i] = 0x21
|
||||||
}
|
}
|
||||||
if m.PagingInfo != nil {
|
if m.PagingInfo != nil {
|
||||||
{
|
{
|
||||||
|
@ -532,15 +616,20 @@ func (m *HistoryQuery) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
i = encodeVarintWakuStore(dAtA, i, uint64(size))
|
i = encodeVarintWakuStore(dAtA, i, uint64(size))
|
||||||
}
|
}
|
||||||
i--
|
i--
|
||||||
dAtA[i] = 0x12
|
dAtA[i] = 0x1a
|
||||||
}
|
}
|
||||||
if len(m.Topics) > 0 {
|
if len(m.ContentFilters) > 0 {
|
||||||
for iNdEx := len(m.Topics) - 1; iNdEx >= 0; iNdEx-- {
|
for iNdEx := len(m.ContentFilters) - 1; iNdEx >= 0; iNdEx-- {
|
||||||
i -= len(m.Topics[iNdEx])
|
{
|
||||||
copy(dAtA[i:], m.Topics[iNdEx])
|
size, err := m.ContentFilters[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||||
i = encodeVarintWakuStore(dAtA, i, uint64(len(m.Topics[iNdEx])))
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
i -= size
|
||||||
|
i = encodeVarintWakuStore(dAtA, i, uint64(size))
|
||||||
|
}
|
||||||
i--
|
i--
|
||||||
dAtA[i] = 0xa
|
dAtA[i] = 0x12
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return len(dAtA) - i, nil
|
return len(dAtA) - i, nil
|
||||||
|
@ -709,15 +798,31 @@ func (m *PagingInfo) Size() (n int) {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *ContentFilter) Size() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
l = len(m.ContentTopic)
|
||||||
|
if l > 0 {
|
||||||
|
n += 1 + l + sovWakuStore(uint64(l))
|
||||||
|
}
|
||||||
|
if m.XXX_unrecognized != nil {
|
||||||
|
n += len(m.XXX_unrecognized)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
func (m *HistoryQuery) Size() (n int) {
|
func (m *HistoryQuery) Size() (n int) {
|
||||||
if m == nil {
|
if m == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
if len(m.Topics) > 0 {
|
if len(m.ContentFilters) > 0 {
|
||||||
for _, s := range m.Topics {
|
for _, e := range m.ContentFilters {
|
||||||
l = len(s)
|
l = e.Size()
|
||||||
n += 1 + l + sovWakuStore(uint64(l))
|
n += 1 + l + sovWakuStore(uint64(l))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1010,6 +1115,89 @@ func (m *PagingInfo) Unmarshal(dAtA []byte) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
func (m *ContentFilter) 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: ContentFilter: wiretype end group for non-group")
|
||||||
|
}
|
||||||
|
if fieldNum <= 0 {
|
||||||
|
return fmt.Errorf("proto: ContentFilter: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||||
|
}
|
||||||
|
switch fieldNum {
|
||||||
|
case 1:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field ContentTopic", 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.ContentTopic = string(dAtA[iNdEx:postIndex])
|
||||||
|
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 *HistoryQuery) Unmarshal(dAtA []byte) error {
|
func (m *HistoryQuery) Unmarshal(dAtA []byte) error {
|
||||||
l := len(dAtA)
|
l := len(dAtA)
|
||||||
iNdEx := 0
|
iNdEx := 0
|
||||||
|
@ -1039,11 +1227,11 @@ func (m *HistoryQuery) Unmarshal(dAtA []byte) error {
|
||||||
return fmt.Errorf("proto: HistoryQuery: illegal tag %d (wire type %d)", fieldNum, wire)
|
return fmt.Errorf("proto: HistoryQuery: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||||
}
|
}
|
||||||
switch fieldNum {
|
switch fieldNum {
|
||||||
case 1:
|
case 2:
|
||||||
if wireType != 2 {
|
if wireType != 2 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Topics", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field ContentFilters", wireType)
|
||||||
}
|
}
|
||||||
var stringLen uint64
|
var msglen int
|
||||||
for shift := uint(0); ; shift += 7 {
|
for shift := uint(0); ; shift += 7 {
|
||||||
if shift >= 64 {
|
if shift >= 64 {
|
||||||
return ErrIntOverflowWakuStore
|
return ErrIntOverflowWakuStore
|
||||||
|
@ -1053,25 +1241,27 @@ func (m *HistoryQuery) Unmarshal(dAtA []byte) error {
|
||||||
}
|
}
|
||||||
b := dAtA[iNdEx]
|
b := dAtA[iNdEx]
|
||||||
iNdEx++
|
iNdEx++
|
||||||
stringLen |= uint64(b&0x7F) << shift
|
msglen |= int(b&0x7F) << shift
|
||||||
if b < 0x80 {
|
if b < 0x80 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
intStringLen := int(stringLen)
|
if msglen < 0 {
|
||||||
if intStringLen < 0 {
|
|
||||||
return ErrInvalidLengthWakuStore
|
return ErrInvalidLengthWakuStore
|
||||||
}
|
}
|
||||||
postIndex := iNdEx + intStringLen
|
postIndex := iNdEx + msglen
|
||||||
if postIndex < 0 {
|
if postIndex < 0 {
|
||||||
return ErrInvalidLengthWakuStore
|
return ErrInvalidLengthWakuStore
|
||||||
}
|
}
|
||||||
if postIndex > l {
|
if postIndex > l {
|
||||||
return io.ErrUnexpectedEOF
|
return io.ErrUnexpectedEOF
|
||||||
}
|
}
|
||||||
m.Topics = append(m.Topics, string(dAtA[iNdEx:postIndex]))
|
m.ContentFilters = append(m.ContentFilters, &ContentFilter{})
|
||||||
|
if err := m.ContentFilters[len(m.ContentFilters)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
case 2:
|
case 3:
|
||||||
if wireType != 2 {
|
if wireType != 2 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field PagingInfo", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field PagingInfo", wireType)
|
||||||
}
|
}
|
||||||
|
@ -1107,7 +1297,7 @@ func (m *HistoryQuery) Unmarshal(dAtA []byte) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
case 3:
|
case 4:
|
||||||
if wireType != 1 {
|
if wireType != 1 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType)
|
||||||
}
|
}
|
||||||
|
@ -1118,7 +1308,7 @@ func (m *HistoryQuery) Unmarshal(dAtA []byte) error {
|
||||||
v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:]))
|
v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:]))
|
||||||
iNdEx += 8
|
iNdEx += 8
|
||||||
m.StartTime = float64(math.Float64frombits(v))
|
m.StartTime = float64(math.Float64frombits(v))
|
||||||
case 4:
|
case 5:
|
||||||
if wireType != 1 {
|
if wireType != 1 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,16 +19,20 @@ message PagingInfo {
|
||||||
Direction direction = 3;
|
Direction direction = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message ContentFilter {
|
||||||
|
string contentTopic = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message HistoryQuery {
|
message HistoryQuery {
|
||||||
repeated string topics = 2;
|
repeated ContentFilter contentFilters = 2;
|
||||||
PagingInfo pagingInfo = 3; // used for pagination
|
PagingInfo pagingInfo = 3; // used for pagination
|
||||||
double startTime = 4;
|
double startTime = 4;
|
||||||
double endTime = 5;
|
double endTime = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message HistoryResponse {
|
message HistoryResponse {
|
||||||
repeated WakuMessage messages = 2;
|
repeated WakuMessage messages = 1;
|
||||||
PagingInfo pagingInfo = 3; // used for pagination
|
PagingInfo pagingInfo = 2; // used for pagination
|
||||||
}
|
}
|
||||||
|
|
||||||
message HistoryRPC {
|
message HistoryRPC {
|
||||||
|
|
|
@ -135,15 +135,6 @@ func paginateWithoutIndex(list []IndexedWakuMessage, pinfo *protocol.PagingInfo)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func contains(s []string, e string) bool {
|
|
||||||
for _, a := range s {
|
|
||||||
if a == e {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *WakuStore) FindMessages(query *protocol.HistoryQuery) *protocol.HistoryResponse {
|
func (w *WakuStore) FindMessages(query *protocol.HistoryQuery) *protocol.HistoryResponse {
|
||||||
result := new(protocol.HistoryResponse)
|
result := new(protocol.HistoryResponse)
|
||||||
// data holds IndexedWakuMessage whose topics match the query
|
// data holds IndexedWakuMessage whose topics match the query
|
||||||
|
@ -157,9 +148,12 @@ func (w *WakuStore) FindMessages(query *protocol.HistoryQuery) *protocol.History
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if contains(query.Topics, indexedMsg.msg.ContentTopic) {
|
for _, cf := range query.ContentFilters {
|
||||||
data = append(data, indexedMsg)
|
if cf.ContentTopic == indexedMsg.msg.ContentTopic {
|
||||||
|
data = append(data, indexedMsg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Messages, result.PagingInfo = paginateWithoutIndex(data, query.PagingInfo)
|
result.Messages, result.PagingInfo = paginateWithoutIndex(data, query.PagingInfo)
|
||||||
|
|
Loading…
Reference in New Issue