From d6c20b59fcbedc713861f2ae61fe9e6bd142f24f Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 29 Sep 2020 18:05:54 +0300 Subject: [PATCH] remove multi-topic message support --- compat/compat.pb.go | 598 +++++++++++++++ compat/compat.proto | 12 + compat_test.go | 83 +++ floodsub.go | 15 +- gossipsub.go | 28 +- gossipsub_spam_test.go | 8 +- mcache.go | 13 +- mcache_test.go | 9 +- pb/rpc.pb.go | 123 ++-- pb/rpc.proto | 2 +- pb/trace.pb.go | 1573 ++++++++++++++++++++++------------------ pb/trace.proto | 10 +- peer_gater.go | 6 +- pubsub.go | 35 +- randomsub.go | 25 +- score.go | 91 ++- score_test.go | 22 +- sign_test.go | 9 +- tag_tracer.go | 9 +- tag_tracer_test.go | 19 +- topic.go | 8 +- trace.go | 10 +- validation.go | 14 +- validation_test.go | 475 ------------ 24 files changed, 1761 insertions(+), 1436 deletions(-) create mode 100644 compat/compat.pb.go create mode 100644 compat/compat.proto create mode 100644 compat_test.go diff --git a/compat/compat.pb.go b/compat/compat.pb.go new file mode 100644 index 00000000..607b78ac --- /dev/null +++ b/compat/compat.pb.go @@ -0,0 +1,598 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: compat.proto + +package compat_pb + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// 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 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.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Message struct { + From []byte `protobuf:"bytes,1,opt,name=from" json:"from,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=data" json:"data,omitempty"` + Seqno []byte `protobuf:"bytes,3,opt,name=seqno" json:"seqno,omitempty"` + TopicIDs []string `protobuf:"bytes,4,rep,name=topicIDs" json:"topicIDs,omitempty"` + Signature []byte `protobuf:"bytes,5,opt,name=signature" json:"signature,omitempty"` + Key []byte `protobuf:"bytes,6,opt,name=key" json:"key,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Message) Reset() { *m = Message{} } +func (m *Message) String() string { return proto.CompactTextString(m) } +func (*Message) ProtoMessage() {} +func (*Message) Descriptor() ([]byte, []int) { + return fileDescriptor_bced3ff93dcaa7f8, []int{0} +} +func (m *Message) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Message.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 *Message) XXX_Merge(src proto.Message) { + xxx_messageInfo_Message.Merge(m, src) +} +func (m *Message) XXX_Size() int { + return m.Size() +} +func (m *Message) XXX_DiscardUnknown() { + xxx_messageInfo_Message.DiscardUnknown(m) +} + +var xxx_messageInfo_Message proto.InternalMessageInfo + +func (m *Message) GetFrom() []byte { + if m != nil { + return m.From + } + return nil +} + +func (m *Message) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + +func (m *Message) GetSeqno() []byte { + if m != nil { + return m.Seqno + } + return nil +} + +func (m *Message) GetTopicIDs() []string { + if m != nil { + return m.TopicIDs + } + return nil +} + +func (m *Message) GetSignature() []byte { + if m != nil { + return m.Signature + } + return nil +} + +func (m *Message) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func init() { + proto.RegisterType((*Message)(nil), "compat.pb.Message") +} + +func init() { proto.RegisterFile("compat.proto", fileDescriptor_bced3ff93dcaa7f8) } + +var fileDescriptor_bced3ff93dcaa7f8 = []byte{ + // 165 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x49, 0xce, 0xcf, 0x2d, + 0x48, 0x2c, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x84, 0xf1, 0x92, 0x94, 0x26, 0x33, + 0x72, 0xb1, 0xfb, 0xa6, 0x16, 0x17, 0x27, 0xa6, 0xa7, 0x0a, 0x09, 0x71, 0xb1, 0xa4, 0x15, 0xe5, + 0xe7, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x04, 0x81, 0xd9, 0x20, 0xb1, 0x94, 0xc4, 0x92, 0x44, + 0x09, 0x26, 0x88, 0x18, 0x88, 0x2d, 0x24, 0xc2, 0xc5, 0x5a, 0x9c, 0x5a, 0x98, 0x97, 0x2f, 0xc1, + 0x0c, 0x16, 0x84, 0x70, 0x84, 0xa4, 0xb8, 0x38, 0x4a, 0xf2, 0x0b, 0x32, 0x93, 0x3d, 0x5d, 0x8a, + 0x25, 0x58, 0x14, 0x98, 0x35, 0x38, 0x83, 0xe0, 0x7c, 0x21, 0x19, 0x2e, 0xce, 0xe2, 0xcc, 0xf4, + 0xbc, 0xc4, 0x92, 0xd2, 0xa2, 0x54, 0x09, 0x56, 0xb0, 0x2e, 0x84, 0x80, 0x90, 0x00, 0x17, 0x73, + 0x76, 0x6a, 0xa5, 0x04, 0x1b, 0x58, 0x1c, 0xc4, 0x74, 0xe2, 0x39, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, + 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x51, 0x81, 0xcf, + 0x0e, 0xbd, 0x00, 0x00, 0x00, +} + +func (m *Message) 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 *Message) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Message) 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.Key != nil { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintCompat(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0x32 + } + if m.Signature != nil { + i -= len(m.Signature) + copy(dAtA[i:], m.Signature) + i = encodeVarintCompat(dAtA, i, uint64(len(m.Signature))) + i-- + dAtA[i] = 0x2a + } + if len(m.TopicIDs) > 0 { + for iNdEx := len(m.TopicIDs) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.TopicIDs[iNdEx]) + copy(dAtA[i:], m.TopicIDs[iNdEx]) + i = encodeVarintCompat(dAtA, i, uint64(len(m.TopicIDs[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if m.Seqno != nil { + i -= len(m.Seqno) + copy(dAtA[i:], m.Seqno) + i = encodeVarintCompat(dAtA, i, uint64(len(m.Seqno))) + i-- + dAtA[i] = 0x1a + } + if m.Data != nil { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintCompat(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x12 + } + if m.From != nil { + i -= len(m.From) + copy(dAtA[i:], m.From) + i = encodeVarintCompat(dAtA, i, uint64(len(m.From))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintCompat(dAtA []byte, offset int, v uint64) int { + offset -= sovCompat(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Message) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.From != nil { + l = len(m.From) + n += 1 + l + sovCompat(uint64(l)) + } + if m.Data != nil { + l = len(m.Data) + n += 1 + l + sovCompat(uint64(l)) + } + if m.Seqno != nil { + l = len(m.Seqno) + n += 1 + l + sovCompat(uint64(l)) + } + if len(m.TopicIDs) > 0 { + for _, s := range m.TopicIDs { + l = len(s) + n += 1 + l + sovCompat(uint64(l)) + } + } + if m.Signature != nil { + l = len(m.Signature) + n += 1 + l + sovCompat(uint64(l)) + } + if m.Key != nil { + l = len(m.Key) + n += 1 + l + sovCompat(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func sovCompat(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCompat(x uint64) (n int) { + return sovCompat(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Message) 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 ErrIntOverflowCompat + } + 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: Message: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Message: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field From", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCompat + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.From = append(m.From[:0], dAtA[iNdEx:postIndex]...) + if m.From == nil { + m.From = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCompat + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Seqno", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCompat + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Seqno = append(m.Seqno[:0], dAtA[iNdEx:postIndex]...) + if m.Seqno == nil { + m.Seqno = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TopicIDs", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + 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 ErrInvalidLengthCompat + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TopicIDs = append(m.TopicIDs, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCompat + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...) + if m.Signature == nil { + m.Signature = []byte{} + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCompat + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCompat + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCompat + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCompat(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthCompat + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthCompat + } + 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 skipCompat(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, ErrIntOverflowCompat + } + 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, ErrIntOverflowCompat + } + 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, ErrIntOverflowCompat + } + 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, ErrInvalidLengthCompat + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCompat + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCompat + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCompat = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCompat = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCompat = fmt.Errorf("proto: unexpected end of group") +) diff --git a/compat/compat.proto b/compat/compat.proto new file mode 100644 index 00000000..30a82708 --- /dev/null +++ b/compat/compat.proto @@ -0,0 +1,12 @@ +syntax = "proto2"; + +package compat.pb; + +message Message { + optional bytes from = 1; + optional bytes data = 2; + optional bytes seqno = 3; + repeated string topicIDs = 4; + optional bytes signature = 5; + optional bytes key = 6; +} diff --git a/compat_test.go b/compat_test.go new file mode 100644 index 00000000..110c34a2 --- /dev/null +++ b/compat_test.go @@ -0,0 +1,83 @@ +package pubsub + +import ( + "testing" + + compat_pb "github.com/libp2p/go-libp2p-pubsub/compat" + pb "github.com/libp2p/go-libp2p-pubsub/pb" +) + +func TestMultitopicMessageCompatibility(t *testing.T) { + topic1 := "topic1" + topic2 := "topic2" + + newMessage1 := &pb.Message{ + From: []byte("A"), + Data: []byte("blah"), + Seqno: []byte("123"), + Topic: &topic1, + Signature: []byte("a-signature"), + Key: []byte("a-key"), + } + oldMessage1 := &compat_pb.Message{ + From: []byte("A"), + Data: []byte("blah"), + Seqno: []byte("123"), + TopicIDs: []string{topic1}, + Signature: []byte("a-signature"), + Key: []byte("a-key"), + } + oldMessage2 := &compat_pb.Message{ + From: []byte("A"), + Data: []byte("blah"), + Seqno: []byte("123"), + TopicIDs: []string{topic1, topic2}, + Signature: []byte("a-signature"), + Key: []byte("a-key"), + } + + newMessage1b, err := newMessage1.Marshal() + if err != nil { + t.Fatal(err) + } + oldMessage1b, err := oldMessage1.Marshal() + if err != nil { + t.Fatal(err) + } + oldMessage2b, err := oldMessage2.Marshal() + if err != nil { + t.Fatal(err) + } + + newMessage := new(pb.Message) + oldMessage := new(compat_pb.Message) + + err = newMessage.Unmarshal(oldMessage1b) + if err != nil { + t.Fatal(err) + } + if newMessage.GetTopic() != topic1 { + t.Fatalf("bad topic: expected %s, got %s", topic1, newMessage.GetTopic()) + } + + newMessage.Reset() + err = newMessage.Unmarshal(oldMessage2b) + if err != nil { + t.Fatal(err) + } + if newMessage.GetTopic() != topic2 { + t.Fatalf("bad topic: expected %s, got %s", topic2, newMessage.GetTopic()) + } + + err = oldMessage.Unmarshal(newMessage1b) + if err != nil { + t.Fatal(err) + } + topics := oldMessage.GetTopicIDs() + if len(topics) != 1 { + t.Fatalf("expected 1 topic, got %d", len(topics)) + } + if topics[0] != topic1 { + t.Fatalf("bad topic: expected %s, got %s", topic1, topics[0]) + } +} diff --git a/floodsub.go b/floodsub.go index 5490efc5..04f6d894 100644 --- a/floodsub.go +++ b/floodsub.go @@ -75,21 +75,10 @@ func (fs *FloodSubRouter) HandleRPC(rpc *RPC) {} func (fs *FloodSubRouter) Publish(msg *Message) { from := msg.ReceivedFrom - - tosend := make(map[peer.ID]struct{}) - for _, topic := range msg.GetTopicIDs() { - tmap, ok := fs.p.topics[topic] - if !ok { - continue - } - - for p := range tmap { - tosend[p] = struct{}{} - } - } + topic := msg.GetTopic() out := rpcWithMessages(msg.Message) - for pid := range tosend { + for pid := range fs.p.topics[topic] { if pid == from || pid == peer.ID(msg.GetFrom()) { continue } diff --git a/gossipsub.go b/gossipsub.go index e1fddede..e3c9809f 100644 --- a/gossipsub.go +++ b/gossipsub.go @@ -869,26 +869,26 @@ func (gs *GossipSubRouter) connector() { func (gs *GossipSubRouter) Publish(msg *Message) { gs.mcache.Put(msg.Message) + from := msg.ReceivedFrom + topic := msg.GetTopic() tosend := make(map[peer.ID]struct{}) - for _, topic := range msg.GetTopicIDs() { - // any peers in the topic? - tmap, ok := gs.p.topics[topic] - if !ok { - continue - } - if gs.floodPublish && from == gs.p.host.ID() { - for p := range tmap { - _, direct := gs.direct[p] - if direct || gs.score.Score(p) >= gs.publishThreshold { - tosend[p] = struct{}{} - } + // any peers in the topic? + tmap, ok := gs.p.topics[topic] + if !ok { + return + } + + if gs.floodPublish && from == gs.p.host.ID() { + for p := range tmap { + _, direct := gs.direct[p] + if direct || gs.score.Score(p) >= gs.publishThreshold { + tosend[p] = struct{}{} } - continue } - + } else { // direct peers for p := range gs.direct { _, inTopic := tmap[p] diff --git a/gossipsub_spam_test.go b/gossipsub_spam_test.go index 38a23260..c5d2e70c 100644 --- a/gossipsub_spam_test.go +++ b/gossipsub_spam_test.go @@ -662,10 +662,10 @@ func TestGossipsubAttackInvalidMessageSpam(t *testing.T) { // fail validation and reduce the attacker's score) for i := 0; i < 100; i++ { msg := &pb.Message{ - Data: []byte("some data" + strconv.Itoa(i)), - TopicIDs: []string{mytopic}, - From: []byte(attacker.ID()), - Seqno: []byte{byte(i + 1)}, + Data: []byte("some data" + strconv.Itoa(i)), + Topic: &mytopic, + From: []byte(attacker.ID()), + Seqno: []byte{byte(i + 1)}, } writeMsg(&pb.RPC{ Publish: []*pb.Message{msg}, diff --git a/mcache.go b/mcache.go index 86154cb6..e1f02ab3 100644 --- a/mcache.go +++ b/mcache.go @@ -48,14 +48,14 @@ func (mc *MessageCache) SetMsgIdFn(msgID MsgIdFunction) { } type CacheEntry struct { - mid string - topics []string + mid string + topic string } func (mc *MessageCache) Put(msg *pb.Message) { mid := mc.msgID(msg) mc.msgs[mid] = msg - mc.history[0] = append(mc.history[0], CacheEntry{mid: mid, topics: msg.GetTopicIDs()}) + mc.history[0] = append(mc.history[0], CacheEntry{mid: mid, topic: msg.GetTopic()}) } func (mc *MessageCache) Get(mid string) (*pb.Message, bool) { @@ -83,11 +83,8 @@ func (mc *MessageCache) GetGossipIDs(topic string) []string { var mids []string for _, entries := range mc.history[:mc.gossip] { for _, entry := range entries { - for _, t := range entry.topics { - if t == topic { - mids = append(mids, entry.mid) - break - } + if entry.topic == topic { + mids = append(mids, entry.mid) } } } diff --git a/mcache_test.go b/mcache_test.go index e8a50f38..e36c6b19 100644 --- a/mcache_test.go +++ b/mcache_test.go @@ -157,10 +157,11 @@ func makeTestMessage(n int) *pb.Message { seqno := make([]byte, 8) binary.BigEndian.PutUint64(seqno, uint64(n)) data := []byte(fmt.Sprintf("%d", n)) + topic := "test" return &pb.Message{ - Data: data, - TopicIDs: []string{"test"}, - From: []byte("test"), - Seqno: seqno, + Data: data, + Topic: &topic, + From: []byte("test"), + Seqno: seqno, } } diff --git a/pb/rpc.pb.go b/pb/rpc.pb.go index 34bdf1e7..099e61d8 100644 --- a/pb/rpc.pb.go +++ b/pb/rpc.pb.go @@ -230,7 +230,7 @@ type Message struct { From []byte `protobuf:"bytes,1,opt,name=from" json:"from,omitempty"` Data []byte `protobuf:"bytes,2,opt,name=data" json:"data,omitempty"` Seqno []byte `protobuf:"bytes,3,opt,name=seqno" json:"seqno,omitempty"` - TopicIDs []string `protobuf:"bytes,4,rep,name=topicIDs" json:"topicIDs,omitempty"` + Topic *string `protobuf:"bytes,4,opt,name=topic" json:"topic,omitempty"` Signature []byte `protobuf:"bytes,5,opt,name=signature" json:"signature,omitempty"` Key []byte `protobuf:"bytes,6,opt,name=key" json:"key,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -292,11 +292,11 @@ func (m *Message) GetSeqno() []byte { return nil } -func (m *Message) GetTopicIDs() []string { - if m != nil { - return m.TopicIDs +func (m *Message) GetTopic() string { + if m != nil && m.Topic != nil { + return *m.Topic } - return nil + return "" } func (m *Message) GetSignature() []byte { @@ -846,49 +846,49 @@ func init() { func init() { proto.RegisterFile("rpc.proto", fileDescriptor_77a6da22d6a3feb1) } var fileDescriptor_77a6da22d6a3feb1 = []byte{ - // 668 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xcd, 0x6e, 0xd3, 0x4a, - 0x14, 0xc7, 0xef, 0xc4, 0x49, 0x1d, 0x9f, 0xba, 0xbd, 0xd1, 0xdc, 0xab, 0x5e, 0xdf, 0xa8, 0x8a, - 0x22, 0x23, 0xa1, 0x50, 0x8a, 0x17, 0x01, 0x89, 0x0d, 0x42, 0x94, 0x26, 0x22, 0x11, 0x6a, 0x1b, - 0x4d, 0x2b, 0x55, 0x2c, 0x6d, 0x67, 0xd2, 0x58, 0x69, 0x3c, 0xc6, 0x1f, 0x45, 0x7d, 0x03, 0xf6, - 0xf0, 0x2c, 0x3c, 0x03, 0x0b, 0x16, 0x3c, 0x02, 0xea, 0x8e, 0xb7, 0x40, 0x73, 0x3c, 0x4e, 0x9c, - 0x7e, 0xc1, 0xca, 0x67, 0x8e, 0x7f, 0xff, 0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 0x1c, 0x0f, 0xf6, 0x58, 0xbf, 0xb7, - 0x6a, 0xeb, 0xb5, 0xf9, 0xf5, 0xaa, 0x45, 0xbe, 0x5f, 0xb5, 0xc8, 0x8f, 0xab, 0x16, 0xf9, 0x15, - 0x00, 0x00, 0xff, 0xff, 0xd4, 0xb4, 0x37, 0x28, 0x91, 0x05, 0x00, 0x00, + // 662 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xcf, 0x6e, 0xd3, 0x4a, + 0x14, 0xc6, 0xef, 0xd4, 0x4e, 0x1d, 0x9f, 0xba, 0xbd, 0xd1, 0xdc, 0xab, 0x62, 0xaa, 0x2a, 0x8a, + 0x8c, 0x84, 0x42, 0x29, 0x5e, 0x04, 0x24, 0x36, 0x08, 0x51, 0x9a, 0x88, 0x44, 0xa8, 0x6d, 0x34, + 0xad, 0x54, 0xb1, 0xb4, 0x9d, 0x49, 0x63, 0xa5, 0xf1, 0x18, 0xff, 0x29, 0xea, 0x1b, 0xb0, 0x61, + 0xc7, 0xb3, 0xf0, 0x0c, 0x2c, 0x58, 0xf0, 0x08, 0xa8, 0x3b, 0xde, 0x02, 0xcd, 0xf1, 0x38, 0x71, + 0x5a, 0x5a, 0x58, 0xf9, 0xcc, 0x99, 0xdf, 0x77, 0xce, 0x37, 0xc7, 0x33, 0x60, 0x26, 0x71, 0xe0, + 0xc6, 0x89, 0xc8, 0x04, 0x35, 0xe3, 0xdc, 0x4f, 0x73, 0xdf, 0x8d, 0x7d, 0xe7, 0x27, 0x01, 0x8d, + 0x0d, 0xf7, 0xe9, 0x0b, 0x58, 0x4f, 0x73, 0x3f, 0x0d, 0x92, 0x30, 0xce, 0x42, 0x11, 0xa5, 0x36, + 0x69, 0x69, 0xed, 0xb5, 0xce, 0xa6, 0x3b, 0x47, 0x5d, 0x36, 0xdc, 0x77, 0x8f, 0x73, 0xff, 0x28, + 0xce, 0x52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f, + 0x34, 0x0a, 0xe8, 0x33, 0xd0, 0x78, 0x14, 0xa8, 0x67, 0xe9, 0xdc, 0xa1, 0xeb, 0x45, 0x01, 0xca, + 0x24, 0xbe, 0xf5, 0x91, 0x40, 0xbd, 0x2c, 0x44, 0x5f, 0x81, 0x3e, 0x13, 0xa3, 0xc2, 0xcf, 0x46, + 0x67, 0xf7, 0x2f, 0x7a, 0x63, 0x70, 0x20, 0x46, 0x9c, 0xa1, 0x52, 0x9e, 0x68, 0xca, 0x2f, 0x8b, + 0xc9, 0x5b, 0x0c, 0x63, 0xe7, 0x61, 0xd1, 0x41, 0x52, 0xb4, 0x0e, 0xfa, 0xe1, 0xd1, 0x61, 0xaf, + 0xf1, 0x0f, 0x35, 0x40, 0x7b, 0xdb, 0x7b, 0xd7, 0x20, 0x32, 0x38, 0x3d, 0x3a, 0x69, 0xac, 0x6c, + 0x7d, 0x26, 0x60, 0x28, 0x6f, 0xf4, 0xe5, 0x92, 0x93, 0x9d, 0x3f, 0x9f, 0x46, 0x7e, 0x2b, 0x3e, + 0xb6, 0xc1, 0x9c, 0xf2, 0xcb, 0xbe, 0x97, 0x4e, 0x78, 0x69, 0x66, 0x91, 0x70, 0x1e, 0x63, 0xa3, + 0x6b, 0x86, 0xd6, 0xc1, 0x3c, 0xee, 0xef, 0xb1, 0x5e, 0x77, 0xd9, 0xd6, 0x6b, 0xeb, 0xeb, 0x55, + 0x93, 0x7c, 0xbf, 0x6a, 0x92, 0x1f, 0x57, 0x4d, 0xf2, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x52, + 0x7a, 0xa2, 0x8b, 0x05, 0x00, 0x00, } func (m *RPC) Marshal() (dAtA []byte, err error) { @@ -1040,14 +1040,12 @@ func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a } - if len(m.TopicIDs) > 0 { - for iNdEx := len(m.TopicIDs) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.TopicIDs[iNdEx]) - copy(dAtA[i:], m.TopicIDs[iNdEx]) - i = encodeVarintRpc(dAtA, i, uint64(len(m.TopicIDs[iNdEx]))) - i-- - dAtA[i] = 0x22 - } + if m.Topic != nil { + i -= len(*m.Topic) + copy(dAtA[i:], *m.Topic) + i = encodeVarintRpc(dAtA, i, uint64(len(*m.Topic))) + i-- + dAtA[i] = 0x22 } if m.Seqno != nil { i -= len(m.Seqno) @@ -1579,11 +1577,9 @@ func (m *Message) Size() (n int) { l = len(m.Seqno) n += 1 + l + sovRpc(uint64(l)) } - if len(m.TopicIDs) > 0 { - for _, s := range m.TopicIDs { - l = len(s) - n += 1 + l + sovRpc(uint64(l)) - } + if m.Topic != nil { + l = len(*m.Topic) + n += 1 + l + sovRpc(uint64(l)) } if m.Signature != nil { l = len(m.Signature) @@ -2207,7 +2203,7 @@ func (m *Message) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TopicIDs", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Topic", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2235,7 +2231,8 @@ func (m *Message) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TopicIDs = append(m.TopicIDs, string(dAtA[iNdEx:postIndex])) + s := string(dAtA[iNdEx:postIndex]) + m.Topic = &s iNdEx = postIndex case 5: if wireType != 2 { diff --git a/pb/rpc.proto b/pb/rpc.proto index a060ffff..1a9a85bc 100644 --- a/pb/rpc.proto +++ b/pb/rpc.proto @@ -18,7 +18,7 @@ message Message { optional bytes from = 1; optional bytes data = 2; optional bytes seqno = 3; - repeated string topicIDs = 4; + optional string topic = 4; optional bytes signature = 5; optional bytes key = 6; } diff --git a/pb/trace.pb.go b/pb/trace.pb.go index 75c1f786..26b58c07 100644 --- a/pb/trace.pb.go +++ b/pb/trace.pb.go @@ -8,6 +8,7 @@ import ( proto "github.com/gogo/protobuf/proto" io "io" math "math" + math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. @@ -19,7 +20,7 @@ var _ = math.Inf // 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.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type TraceEvent_Type int32 @@ -130,7 +131,7 @@ func (m *TraceEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_TraceEvent.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -263,7 +264,7 @@ func (m *TraceEvent) GetPrune() *TraceEvent_Prune { type TraceEvent_PublishMessage struct { MessageID []byte `protobuf:"bytes,1,opt,name=messageID" json:"messageID,omitempty"` - Topics []string `protobuf:"bytes,2,rep,name=topics" json:"topics,omitempty"` + Topic *string `protobuf:"bytes,2,opt,name=topic" json:"topic,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -283,7 +284,7 @@ func (m *TraceEvent_PublishMessage) XXX_Marshal(b []byte, deterministic bool) ([ return xxx_messageInfo_TraceEvent_PublishMessage.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -309,18 +310,18 @@ func (m *TraceEvent_PublishMessage) GetMessageID() []byte { return nil } -func (m *TraceEvent_PublishMessage) GetTopics() []string { - if m != nil { - return m.Topics +func (m *TraceEvent_PublishMessage) GetTopic() string { + if m != nil && m.Topic != nil { + return *m.Topic } - return nil + return "" } type TraceEvent_RejectMessage struct { MessageID []byte `protobuf:"bytes,1,opt,name=messageID" json:"messageID,omitempty"` ReceivedFrom []byte `protobuf:"bytes,2,opt,name=receivedFrom" json:"receivedFrom,omitempty"` Reason *string `protobuf:"bytes,3,opt,name=reason" json:"reason,omitempty"` - Topics []string `protobuf:"bytes,4,rep,name=topics" json:"topics,omitempty"` + Topic *string `protobuf:"bytes,4,opt,name=topic" json:"topic,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -340,7 +341,7 @@ func (m *TraceEvent_RejectMessage) XXX_Marshal(b []byte, deterministic bool) ([] return xxx_messageInfo_TraceEvent_RejectMessage.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -380,17 +381,17 @@ func (m *TraceEvent_RejectMessage) GetReason() string { return "" } -func (m *TraceEvent_RejectMessage) GetTopics() []string { - if m != nil { - return m.Topics +func (m *TraceEvent_RejectMessage) GetTopic() string { + if m != nil && m.Topic != nil { + return *m.Topic } - return nil + return "" } type TraceEvent_DuplicateMessage struct { MessageID []byte `protobuf:"bytes,1,opt,name=messageID" json:"messageID,omitempty"` ReceivedFrom []byte `protobuf:"bytes,2,opt,name=receivedFrom" json:"receivedFrom,omitempty"` - Topics []string `protobuf:"bytes,3,rep,name=topics" json:"topics,omitempty"` + Topic *string `protobuf:"bytes,3,opt,name=topic" json:"topic,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -410,7 +411,7 @@ func (m *TraceEvent_DuplicateMessage) XXX_Marshal(b []byte, deterministic bool) return xxx_messageInfo_TraceEvent_DuplicateMessage.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -443,16 +444,16 @@ func (m *TraceEvent_DuplicateMessage) GetReceivedFrom() []byte { return nil } -func (m *TraceEvent_DuplicateMessage) GetTopics() []string { - if m != nil { - return m.Topics +func (m *TraceEvent_DuplicateMessage) GetTopic() string { + if m != nil && m.Topic != nil { + return *m.Topic } - return nil + return "" } type TraceEvent_DeliverMessage struct { MessageID []byte `protobuf:"bytes,1,opt,name=messageID" json:"messageID,omitempty"` - Topics []string `protobuf:"bytes,2,rep,name=topics" json:"topics,omitempty"` + Topic *string `protobuf:"bytes,2,opt,name=topic" json:"topic,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -472,7 +473,7 @@ func (m *TraceEvent_DeliverMessage) XXX_Marshal(b []byte, deterministic bool) ([ return xxx_messageInfo_TraceEvent_DeliverMessage.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -498,11 +499,11 @@ func (m *TraceEvent_DeliverMessage) GetMessageID() []byte { return nil } -func (m *TraceEvent_DeliverMessage) GetTopics() []string { - if m != nil { - return m.Topics +func (m *TraceEvent_DeliverMessage) GetTopic() string { + if m != nil && m.Topic != nil { + return *m.Topic } - return nil + return "" } type TraceEvent_AddPeer struct { @@ -527,7 +528,7 @@ func (m *TraceEvent_AddPeer) XXX_Marshal(b []byte, deterministic bool) ([]byte, return xxx_messageInfo_TraceEvent_AddPeer.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -581,7 +582,7 @@ func (m *TraceEvent_RemovePeer) XXX_Marshal(b []byte, deterministic bool) ([]byt return xxx_messageInfo_TraceEvent_RemovePeer.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -629,7 +630,7 @@ func (m *TraceEvent_RecvRPC) XXX_Marshal(b []byte, deterministic bool) ([]byte, return xxx_messageInfo_TraceEvent_RecvRPC.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -684,7 +685,7 @@ func (m *TraceEvent_SendRPC) XXX_Marshal(b []byte, deterministic bool) ([]byte, return xxx_messageInfo_TraceEvent_SendRPC.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -739,7 +740,7 @@ func (m *TraceEvent_DropRPC) XXX_Marshal(b []byte, deterministic bool) ([]byte, return xxx_messageInfo_TraceEvent_DropRPC.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -793,7 +794,7 @@ func (m *TraceEvent_Join) XXX_Marshal(b []byte, deterministic bool) ([]byte, err return xxx_messageInfo_TraceEvent_Join.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -840,7 +841,7 @@ func (m *TraceEvent_Leave) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return xxx_messageInfo_TraceEvent_Leave.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -888,7 +889,7 @@ func (m *TraceEvent_Graft) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return xxx_messageInfo_TraceEvent_Graft.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -943,7 +944,7 @@ func (m *TraceEvent_Prune) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return xxx_messageInfo_TraceEvent_Prune.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -999,7 +1000,7 @@ func (m *TraceEvent_RPCMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, return xxx_messageInfo_TraceEvent_RPCMeta.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -1041,7 +1042,7 @@ func (m *TraceEvent_RPCMeta) GetControl() *TraceEvent_ControlMeta { type TraceEvent_MessageMeta struct { MessageID []byte `protobuf:"bytes,1,opt,name=messageID" json:"messageID,omitempty"` - Topics []string `protobuf:"bytes,2,rep,name=topics" json:"topics,omitempty"` + Topic *string `protobuf:"bytes,2,opt,name=topic" json:"topic,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -1061,7 +1062,7 @@ func (m *TraceEvent_MessageMeta) XXX_Marshal(b []byte, deterministic bool) ([]by return xxx_messageInfo_TraceEvent_MessageMeta.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -1087,11 +1088,11 @@ func (m *TraceEvent_MessageMeta) GetMessageID() []byte { return nil } -func (m *TraceEvent_MessageMeta) GetTopics() []string { - if m != nil { - return m.Topics +func (m *TraceEvent_MessageMeta) GetTopic() string { + if m != nil && m.Topic != nil { + return *m.Topic } - return nil + return "" } type TraceEvent_SubMeta struct { @@ -1116,7 +1117,7 @@ func (m *TraceEvent_SubMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, return xxx_messageInfo_TraceEvent_SubMeta.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -1173,7 +1174,7 @@ func (m *TraceEvent_ControlMeta) XXX_Marshal(b []byte, deterministic bool) ([]by return xxx_messageInfo_TraceEvent_ControlMeta.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -1242,7 +1243,7 @@ func (m *TraceEvent_ControlIHaveMeta) XXX_Marshal(b []byte, deterministic bool) return xxx_messageInfo_TraceEvent_ControlIHaveMeta.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -1296,7 +1297,7 @@ func (m *TraceEvent_ControlIWantMeta) XXX_Marshal(b []byte, deterministic bool) return xxx_messageInfo_TraceEvent_ControlIWantMeta.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -1343,7 +1344,7 @@ func (m *TraceEvent_ControlGraftMeta) XXX_Marshal(b []byte, deterministic bool) return xxx_messageInfo_TraceEvent_ControlGraftMeta.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -1391,7 +1392,7 @@ func (m *TraceEvent_ControlPruneMeta) XXX_Marshal(b []byte, deterministic bool) return xxx_messageInfo_TraceEvent_ControlPruneMeta.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -1445,7 +1446,7 @@ func (m *TraceEventBatch) XXX_Marshal(b []byte, deterministic bool) ([]byte, err return xxx_messageInfo_TraceEventBatch.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } @@ -1501,70 +1502,76 @@ func init() { func init() { proto.RegisterFile("trace.proto", fileDescriptor_0571941a1d628a80) } var fileDescriptor_0571941a1d628a80 = []byte{ - // 906 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x96, 0xd1, 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 0x08, 0x34, 0xc7, 0xba, 0xb2, - 0x7a, 0xa3, 0x7c, 0x4d, 0x40, 0x87, 0x70, 0x60, 0xde, 0xd9, 0x83, 0x7e, 0xaf, 0x3b, 0xb2, 0xf2, - 0xe5, 0x3d, 0xaa, 0x37, 0xad, 0x41, 0xff, 0xde, 0x72, 0xf2, 0xc5, 0x0a, 0x52, 0xa1, 0xd6, 0x35, - 0xcd, 0x07, 0xdb, 0xb2, 0x1c, 0x5d, 0x44, 0xfb, 0x50, 0x77, 0xac, 0xeb, 0xdb, 0x7b, 0x8b, 0x2f, - 0x48, 0xf4, 0xb3, 0x63, 0xf5, 0xee, 0x1f, 0x1c, 0xbb, 0xa7, 0x57, 0xe9, 0x6c, 0x68, 0xdd, 0x98, - 0x6c, 0x26, 0xd3, 0x99, 0xe9, 0xdc, 0xda, 0x6c, 0x56, 0x43, 0x35, 0x10, 0xaf, 0x6e, 0xfb, 0x37, - 0xba, 0x82, 0x14, 0x90, 0x06, 0x56, 0xf7, 0xde, 0xd2, 0x81, 0x0e, 0x2f, 0x9d, 0xee, 0xc5, 0x48, - 0xaf, 0xd3, 0xa1, 0xed, 0xdc, 0xdd, 0x58, 0xba, 0x7a, 0xfc, 0x0d, 0xec, 0x2f, 0x0f, 0xe9, 0xdc, - 0x25, 0xde, 0x23, 0x7a, 0x0e, 0xd2, 0x98, 0x0e, 0x52, 0xd3, 0x1d, 0x96, 0x9e, 0xe7, 0xb9, 0xfa, - 0xfb, 0xd3, 0x91, 0xf0, 0xe7, 0xd3, 0x91, 0xf0, 0xd7, 0xd3, 0x91, 0xf0, 0x4f, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x99, 0xba, 0xca, 0x75, 0x8a, 0x09, 0x00, 0x00, + // 993 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0xcf, 0x6e, 0xdb, 0x46, + 0x10, 0xc6, 0x4b, 0x4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0x1b, 0xab, 0x0d, 0xfe, 0x69, 0xe2, 0xe5, 0x99, 0xa1, 0x36, 0xf7, 0xdf, 0xc2, + 0x6e, 0x72, 0xbf, 0x87, 0x16, 0x9b, 0xde, 0x90, 0x1f, 0xa0, 0x32, 0xe1, 0x1f, 0xe1, 0x10, 0x3f, + 0xce, 0x1d, 0x05, 0x94, 0x9a, 0xc3, 0xe6, 0xc7, 0xbb, 0x3d, 0xe5, 0x9f, 0xbb, 0x3d, 0xe5, 0xdf, + 0xbb, 0x3d, 0xe5, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x92, 0xe3, 0x70, 0x55, 0xa5, 0x0b, 0x00, + 0x00, } func (m *TraceEvent) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1572,168 +1579,201 @@ func (m *TraceEvent) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.Type != nil { - dAtA[i] = 0x8 - i++ - i = encodeVarintTrace(dAtA, i, uint64(*m.Type)) - } - if m.PeerID != nil { - dAtA[i] = 0x12 - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(m.PeerID))) - i += copy(dAtA[i:], m.PeerID) - } - if m.Timestamp != nil { - dAtA[i] = 0x18 - i++ - i = encodeVarintTrace(dAtA, i, uint64(*m.Timestamp)) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } - if m.PublishMessage != nil { - dAtA[i] = 0x22 - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.PublishMessage.Size())) - n1, err := m.PublishMessage.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.Prune != nil { + { + size, err := m.Prune.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n1 + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 } - if m.RejectMessage != nil { - dAtA[i] = 0x2a - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.RejectMessage.Size())) - n2, err := m.RejectMessage.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.Graft != nil { + { + size, err := m.Graft.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n2 + i-- + dAtA[i] = 0x7a } - if m.DuplicateMessage != nil { - dAtA[i] = 0x32 - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.DuplicateMessage.Size())) - n3, err := m.DuplicateMessage.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.Leave != nil { + { + size, err := m.Leave.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n3 + i-- + dAtA[i] = 0x72 } - if m.DeliverMessage != nil { - dAtA[i] = 0x3a - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.DeliverMessage.Size())) - n4, err := m.DeliverMessage.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.Join != nil { + { + size, err := m.Join.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n4 + i-- + dAtA[i] = 0x6a } - if m.AddPeer != nil { - dAtA[i] = 0x42 - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.AddPeer.Size())) - n5, err := m.AddPeer.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.DropRPC != nil { + { + size, err := m.DropRPC.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n5 + i-- + dAtA[i] = 0x62 } - if m.RemovePeer != nil { - dAtA[i] = 0x4a - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.RemovePeer.Size())) - n6, err := m.RemovePeer.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.SendRPC != nil { + { + size, err := m.SendRPC.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n6 + i-- + dAtA[i] = 0x5a } if m.RecvRPC != nil { - dAtA[i] = 0x52 - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.RecvRPC.Size())) - n7, err := m.RecvRPC.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + { + size, err := m.RecvRPC.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n7 + i-- + dAtA[i] = 0x52 } - if m.SendRPC != nil { - dAtA[i] = 0x5a - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.SendRPC.Size())) - n8, err := m.SendRPC.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.RemovePeer != nil { + { + size, err := m.RemovePeer.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n8 + i-- + dAtA[i] = 0x4a } - if m.DropRPC != nil { - dAtA[i] = 0x62 - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.DropRPC.Size())) - n9, err := m.DropRPC.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.AddPeer != nil { + { + size, err := m.AddPeer.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n9 + i-- + dAtA[i] = 0x42 } - if m.Join != nil { - dAtA[i] = 0x6a - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.Join.Size())) - n10, err := m.Join.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.DeliverMessage != nil { + { + size, err := m.DeliverMessage.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n10 + i-- + dAtA[i] = 0x3a } - if m.Leave != nil { - dAtA[i] = 0x72 - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.Leave.Size())) - n11, err := m.Leave.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.DuplicateMessage != nil { + { + size, err := m.DuplicateMessage.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n11 + i-- + dAtA[i] = 0x32 } - if m.Graft != nil { - dAtA[i] = 0x7a - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.Graft.Size())) - n12, err := m.Graft.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.RejectMessage != nil { + { + size, err := m.RejectMessage.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n12 + i-- + dAtA[i] = 0x2a } - if m.Prune != nil { - dAtA[i] = 0x82 - i++ - dAtA[i] = 0x1 - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.Prune.Size())) - n13, err := m.Prune.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if m.PublishMessage != nil { + { + size, err := m.PublishMessage.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n13 + i-- + dAtA[i] = 0x22 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.Timestamp != nil { + i = encodeVarintTrace(dAtA, i, uint64(*m.Timestamp)) + i-- + dAtA[i] = 0x18 } - return i, nil + if m.PeerID != nil { + i -= len(m.PeerID) + copy(dAtA[i:], m.PeerID) + i = encodeVarintTrace(dAtA, i, uint64(len(m.PeerID))) + i-- + dAtA[i] = 0x12 + } + if m.Type != nil { + i = encodeVarintTrace(dAtA, i, uint64(*m.Type)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil } func (m *TraceEvent_PublishMessage) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1741,41 +1781,40 @@ func (m *TraceEvent_PublishMessage) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_PublishMessage) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_PublishMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.MessageID != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(m.MessageID))) - i += copy(dAtA[i:], m.MessageID) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } - if len(m.Topics) > 0 { - for _, s := range m.Topics { - dAtA[i] = 0x12 - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) - } + if m.Topic != nil { + i -= len(*m.Topic) + copy(dAtA[i:], *m.Topic) + i = encodeVarintTrace(dAtA, i, uint64(len(*m.Topic))) + i-- + dAtA[i] = 0x12 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.MessageID != nil { + i -= len(m.MessageID) + copy(dAtA[i:], m.MessageID) + i = encodeVarintTrace(dAtA, i, uint64(len(m.MessageID))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_RejectMessage) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1783,53 +1822,54 @@ func (m *TraceEvent_RejectMessage) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_RejectMessage) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_RejectMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.MessageID != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(m.MessageID))) - i += copy(dAtA[i:], m.MessageID) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } - if m.ReceivedFrom != nil { - dAtA[i] = 0x12 - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(m.ReceivedFrom))) - i += copy(dAtA[i:], m.ReceivedFrom) + if m.Topic != nil { + i -= len(*m.Topic) + copy(dAtA[i:], *m.Topic) + i = encodeVarintTrace(dAtA, i, uint64(len(*m.Topic))) + i-- + dAtA[i] = 0x22 } if m.Reason != nil { - dAtA[i] = 0x1a - i++ + i -= len(*m.Reason) + copy(dAtA[i:], *m.Reason) i = encodeVarintTrace(dAtA, i, uint64(len(*m.Reason))) - i += copy(dAtA[i:], *m.Reason) + i-- + dAtA[i] = 0x1a } - if len(m.Topics) > 0 { - for _, s := range m.Topics { - dAtA[i] = 0x22 - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) - } + if m.ReceivedFrom != nil { + i -= len(m.ReceivedFrom) + copy(dAtA[i:], m.ReceivedFrom) + i = encodeVarintTrace(dAtA, i, uint64(len(m.ReceivedFrom))) + i-- + dAtA[i] = 0x12 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.MessageID != nil { + i -= len(m.MessageID) + copy(dAtA[i:], m.MessageID) + i = encodeVarintTrace(dAtA, i, uint64(len(m.MessageID))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_DuplicateMessage) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1837,47 +1877,47 @@ func (m *TraceEvent_DuplicateMessage) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_DuplicateMessage) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_DuplicateMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.MessageID != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(m.MessageID))) - i += copy(dAtA[i:], m.MessageID) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Topic != nil { + i -= len(*m.Topic) + copy(dAtA[i:], *m.Topic) + i = encodeVarintTrace(dAtA, i, uint64(len(*m.Topic))) + i-- + dAtA[i] = 0x1a } if m.ReceivedFrom != nil { - dAtA[i] = 0x12 - i++ + i -= len(m.ReceivedFrom) + copy(dAtA[i:], m.ReceivedFrom) i = encodeVarintTrace(dAtA, i, uint64(len(m.ReceivedFrom))) - i += copy(dAtA[i:], m.ReceivedFrom) - } - if len(m.Topics) > 0 { - for _, s := range m.Topics { - dAtA[i] = 0x1a - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) - } + i-- + dAtA[i] = 0x12 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.MessageID != nil { + i -= len(m.MessageID) + copy(dAtA[i:], m.MessageID) + i = encodeVarintTrace(dAtA, i, uint64(len(m.MessageID))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_DeliverMessage) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1885,41 +1925,40 @@ func (m *TraceEvent_DeliverMessage) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_DeliverMessage) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_DeliverMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.MessageID != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(m.MessageID))) - i += copy(dAtA[i:], m.MessageID) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } - if len(m.Topics) > 0 { - for _, s := range m.Topics { - dAtA[i] = 0x12 - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) - } + if m.Topic != nil { + i -= len(*m.Topic) + copy(dAtA[i:], *m.Topic) + i = encodeVarintTrace(dAtA, i, uint64(len(*m.Topic))) + i-- + dAtA[i] = 0x12 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.MessageID != nil { + i -= len(m.MessageID) + copy(dAtA[i:], m.MessageID) + i = encodeVarintTrace(dAtA, i, uint64(len(m.MessageID))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_AddPeer) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1927,32 +1966,40 @@ func (m *TraceEvent_AddPeer) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_AddPeer) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_AddPeer) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.PeerID != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(m.PeerID))) - i += copy(dAtA[i:], m.PeerID) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if m.Proto != nil { - dAtA[i] = 0x12 - i++ + i -= len(*m.Proto) + copy(dAtA[i:], *m.Proto) i = encodeVarintTrace(dAtA, i, uint64(len(*m.Proto))) - i += copy(dAtA[i:], *m.Proto) + i-- + dAtA[i] = 0x12 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.PeerID != nil { + i -= len(m.PeerID) + copy(dAtA[i:], m.PeerID) + i = encodeVarintTrace(dAtA, i, uint64(len(m.PeerID))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_RemovePeer) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1960,26 +2007,33 @@ func (m *TraceEvent_RemovePeer) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_RemovePeer) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_RemovePeer) 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.PeerID != nil { - dAtA[i] = 0xa - i++ + i -= len(m.PeerID) + copy(dAtA[i:], m.PeerID) i = encodeVarintTrace(dAtA, i, uint64(len(m.PeerID))) - i += copy(dAtA[i:], m.PeerID) - } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_RecvRPC) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -1987,36 +2041,45 @@ func (m *TraceEvent_RecvRPC) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_RecvRPC) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_RecvRPC) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.ReceivedFrom != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(m.ReceivedFrom))) - i += copy(dAtA[i:], m.ReceivedFrom) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if m.Meta != nil { - dAtA[i] = 0x12 - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.Meta.Size())) - n14, err := m.Meta.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + { + size, err := m.Meta.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n14 + i-- + dAtA[i] = 0x12 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.ReceivedFrom != nil { + i -= len(m.ReceivedFrom) + copy(dAtA[i:], m.ReceivedFrom) + i = encodeVarintTrace(dAtA, i, uint64(len(m.ReceivedFrom))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_SendRPC) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -2024,36 +2087,45 @@ func (m *TraceEvent_SendRPC) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_SendRPC) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_SendRPC) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.SendTo != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(m.SendTo))) - i += copy(dAtA[i:], m.SendTo) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if m.Meta != nil { - dAtA[i] = 0x12 - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.Meta.Size())) - n15, err := m.Meta.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + { + size, err := m.Meta.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n15 + i-- + dAtA[i] = 0x12 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.SendTo != nil { + i -= len(m.SendTo) + copy(dAtA[i:], m.SendTo) + i = encodeVarintTrace(dAtA, i, uint64(len(m.SendTo))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_DropRPC) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -2061,36 +2133,45 @@ func (m *TraceEvent_DropRPC) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_DropRPC) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_DropRPC) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.SendTo != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(m.SendTo))) - i += copy(dAtA[i:], m.SendTo) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if m.Meta != nil { - dAtA[i] = 0x12 - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.Meta.Size())) - n16, err := m.Meta.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + { + size, err := m.Meta.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n16 + i-- + dAtA[i] = 0x12 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.SendTo != nil { + i -= len(m.SendTo) + copy(dAtA[i:], m.SendTo) + i = encodeVarintTrace(dAtA, i, uint64(len(m.SendTo))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_Join) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -2098,26 +2179,33 @@ func (m *TraceEvent_Join) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_Join) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_Join) 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.Topic != nil { - dAtA[i] = 0xa - i++ + i -= len(*m.Topic) + copy(dAtA[i:], *m.Topic) i = encodeVarintTrace(dAtA, i, uint64(len(*m.Topic))) - i += copy(dAtA[i:], *m.Topic) - } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_Leave) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -2125,26 +2213,33 @@ func (m *TraceEvent_Leave) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_Leave) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_Leave) 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.Topic != nil { - dAtA[i] = 0x12 - i++ + i -= len(*m.Topic) + copy(dAtA[i:], *m.Topic) i = encodeVarintTrace(dAtA, i, uint64(len(*m.Topic))) - i += copy(dAtA[i:], *m.Topic) - } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + i-- + dAtA[i] = 0x12 } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_Graft) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -2152,32 +2247,40 @@ func (m *TraceEvent_Graft) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_Graft) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_Graft) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.PeerID != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(m.PeerID))) - i += copy(dAtA[i:], m.PeerID) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if m.Topic != nil { - dAtA[i] = 0x12 - i++ + i -= len(*m.Topic) + copy(dAtA[i:], *m.Topic) i = encodeVarintTrace(dAtA, i, uint64(len(*m.Topic))) - i += copy(dAtA[i:], *m.Topic) + i-- + dAtA[i] = 0x12 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.PeerID != nil { + i -= len(m.PeerID) + copy(dAtA[i:], m.PeerID) + i = encodeVarintTrace(dAtA, i, uint64(len(m.PeerID))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_Prune) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -2185,32 +2288,40 @@ func (m *TraceEvent_Prune) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_Prune) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_Prune) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.PeerID != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(m.PeerID))) - i += copy(dAtA[i:], m.PeerID) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if m.Topic != nil { - dAtA[i] = 0x12 - i++ + i -= len(*m.Topic) + copy(dAtA[i:], *m.Topic) i = encodeVarintTrace(dAtA, i, uint64(len(*m.Topic))) - i += copy(dAtA[i:], *m.Topic) + i-- + dAtA[i] = 0x12 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.PeerID != nil { + i -= len(m.PeerID) + copy(dAtA[i:], m.PeerID) + i = encodeVarintTrace(dAtA, i, uint64(len(m.PeerID))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_RPCMeta) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -2218,54 +2329,66 @@ func (m *TraceEvent_RPCMeta) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_RPCMeta) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_RPCMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.Messages) > 0 { - for _, msg := range m.Messages { - dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) + } + if m.Control != nil { + { + size, err := m.Control.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } - i += n + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x1a } if len(m.Subscription) > 0 { - for _, msg := range m.Subscription { - dAtA[i] = 0x12 - i++ - i = encodeVarintTrace(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + for iNdEx := len(m.Subscription) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Subscription[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n + i-- + dAtA[i] = 0x12 } } - if m.Control != nil { - dAtA[i] = 0x1a - i++ - i = encodeVarintTrace(dAtA, i, uint64(m.Control.Size())) - n17, err := m.Control.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + 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 = encodeVarintTrace(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } - i += n17 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) - } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_MessageMeta) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -2273,41 +2396,40 @@ func (m *TraceEvent_MessageMeta) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_MessageMeta) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_MessageMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.MessageID != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(m.MessageID))) - i += copy(dAtA[i:], m.MessageID) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } - if len(m.Topics) > 0 { - for _, s := range m.Topics { - dAtA[i] = 0x12 - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) - } + if m.Topic != nil { + i -= len(*m.Topic) + copy(dAtA[i:], *m.Topic) + i = encodeVarintTrace(dAtA, i, uint64(len(*m.Topic))) + i-- + dAtA[i] = 0x12 } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.MessageID != nil { + i -= len(m.MessageID) + copy(dAtA[i:], m.MessageID) + i = encodeVarintTrace(dAtA, i, uint64(len(m.MessageID))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_SubMeta) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -2315,36 +2437,43 @@ func (m *TraceEvent_SubMeta) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_SubMeta) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_SubMeta) 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.Topic != nil { + i -= len(*m.Topic) + copy(dAtA[i:], *m.Topic) + i = encodeVarintTrace(dAtA, i, uint64(len(*m.Topic))) + i-- + dAtA[i] = 0x12 + } if m.Subscribe != nil { - dAtA[i] = 0x8 - i++ + i-- if *m.Subscribe { dAtA[i] = 1 } else { dAtA[i] = 0 } - i++ - } - if m.Topic != nil { - dAtA[i] = 0x12 - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(*m.Topic))) - i += copy(dAtA[i:], *m.Topic) - } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + i-- + dAtA[i] = 0x8 } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_ControlMeta) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -2352,68 +2481,82 @@ func (m *TraceEvent_ControlMeta) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_ControlMeta) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_ControlMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.Ihave) > 0 { - for _, msg := range m.Ihave { - dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n - } + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } - if len(m.Iwant) > 0 { - for _, msg := range m.Iwant { - dAtA[i] = 0x12 - i++ - i = encodeVarintTrace(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if len(m.Prune) > 0 { + for iNdEx := len(m.Prune) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Prune[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n + i-- + dAtA[i] = 0x22 } } if len(m.Graft) > 0 { - for _, msg := range m.Graft { - dAtA[i] = 0x1a - i++ - i = encodeVarintTrace(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + for iNdEx := len(m.Graft) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Graft[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n + i-- + dAtA[i] = 0x1a } } - if len(m.Prune) > 0 { - for _, msg := range m.Prune { - dAtA[i] = 0x22 - i++ - i = encodeVarintTrace(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + if len(m.Iwant) > 0 { + for iNdEx := len(m.Iwant) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Iwant[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n + i-- + dAtA[i] = 0x12 } } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if len(m.Ihave) > 0 { + for iNdEx := len(m.Ihave) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Ihave[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_ControlIHaveMeta) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -2421,34 +2564,42 @@ func (m *TraceEvent_ControlIHaveMeta) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_ControlIHaveMeta) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_ControlIHaveMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.Topic != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(*m.Topic))) - i += copy(dAtA[i:], *m.Topic) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if len(m.MessageIDs) > 0 { - for _, b := range m.MessageIDs { + for iNdEx := len(m.MessageIDs) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.MessageIDs[iNdEx]) + copy(dAtA[i:], m.MessageIDs[iNdEx]) + i = encodeVarintTrace(dAtA, i, uint64(len(m.MessageIDs[iNdEx]))) + i-- dAtA[i] = 0x12 - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(b))) - i += copy(dAtA[i:], b) } } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.Topic != nil { + i -= len(*m.Topic) + copy(dAtA[i:], *m.Topic) + i = encodeVarintTrace(dAtA, i, uint64(len(*m.Topic))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_ControlIWantMeta) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -2456,28 +2607,35 @@ func (m *TraceEvent_ControlIWantMeta) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_ControlIWantMeta) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_ControlIWantMeta) 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.MessageIDs) > 0 { - for _, b := range m.MessageIDs { + for iNdEx := len(m.MessageIDs) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.MessageIDs[iNdEx]) + copy(dAtA[i:], m.MessageIDs[iNdEx]) + i = encodeVarintTrace(dAtA, i, uint64(len(m.MessageIDs[iNdEx]))) + i-- dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(b))) - i += copy(dAtA[i:], b) } } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) - } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_ControlGraftMeta) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -2485,26 +2643,33 @@ func (m *TraceEvent_ControlGraftMeta) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_ControlGraftMeta) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_ControlGraftMeta) 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.Topic != nil { - dAtA[i] = 0xa - i++ + i -= len(*m.Topic) + copy(dAtA[i:], *m.Topic) i = encodeVarintTrace(dAtA, i, uint64(len(*m.Topic))) - i += copy(dAtA[i:], *m.Topic) - } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEvent_ControlPruneMeta) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -2512,34 +2677,42 @@ func (m *TraceEvent_ControlPruneMeta) Marshal() (dAtA []byte, err error) { } func (m *TraceEvent_ControlPruneMeta) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEvent_ControlPruneMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if m.Topic != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(*m.Topic))) - i += copy(dAtA[i:], *m.Topic) + if m.XXX_unrecognized != nil { + i -= len(m.XXX_unrecognized) + copy(dAtA[i:], m.XXX_unrecognized) } if len(m.Peers) > 0 { - for _, b := range m.Peers { + for iNdEx := len(m.Peers) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Peers[iNdEx]) + copy(dAtA[i:], m.Peers[iNdEx]) + i = encodeVarintTrace(dAtA, i, uint64(len(m.Peers[iNdEx]))) + i-- dAtA[i] = 0x12 - i++ - i = encodeVarintTrace(dAtA, i, uint64(len(b))) - i += copy(dAtA[i:], b) } } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) + if m.Topic != nil { + i -= len(*m.Topic) + copy(dAtA[i:], *m.Topic) + i = encodeVarintTrace(dAtA, i, uint64(len(*m.Topic))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *TraceEventBatch) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -2547,36 +2720,46 @@ func (m *TraceEventBatch) Marshal() (dAtA []byte, err error) { } func (m *TraceEventBatch) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TraceEventBatch) 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.Batch) > 0 { - for _, msg := range m.Batch { - dAtA[i] = 0xa - i++ - i = encodeVarintTrace(dAtA, i, uint64(msg.Size())) - n, err := msg.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err + for iNdEx := len(m.Batch) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Batch[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTrace(dAtA, i, uint64(size)) } - i += n + i-- + dAtA[i] = 0xa } } - if m.XXX_unrecognized != nil { - i += copy(dAtA[i:], m.XXX_unrecognized) - } - return i, nil + return len(dAtA) - i, nil } func encodeVarintTrace(dAtA []byte, offset int, v uint64) int { + offset -= sovTrace(v) + base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) v >>= 7 offset++ } dAtA[offset] = uint8(v) - return offset + 1 + return base } func (m *TraceEvent) Size() (n int) { if m == nil { @@ -2662,11 +2845,9 @@ func (m *TraceEvent_PublishMessage) Size() (n int) { l = len(m.MessageID) n += 1 + l + sovTrace(uint64(l)) } - if len(m.Topics) > 0 { - for _, s := range m.Topics { - l = len(s) - n += 1 + l + sovTrace(uint64(l)) - } + if m.Topic != nil { + l = len(*m.Topic) + n += 1 + l + sovTrace(uint64(l)) } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) @@ -2692,11 +2873,9 @@ func (m *TraceEvent_RejectMessage) Size() (n int) { l = len(*m.Reason) n += 1 + l + sovTrace(uint64(l)) } - if len(m.Topics) > 0 { - for _, s := range m.Topics { - l = len(s) - n += 1 + l + sovTrace(uint64(l)) - } + if m.Topic != nil { + l = len(*m.Topic) + n += 1 + l + sovTrace(uint64(l)) } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) @@ -2718,11 +2897,9 @@ func (m *TraceEvent_DuplicateMessage) Size() (n int) { l = len(m.ReceivedFrom) n += 1 + l + sovTrace(uint64(l)) } - if len(m.Topics) > 0 { - for _, s := range m.Topics { - l = len(s) - n += 1 + l + sovTrace(uint64(l)) - } + if m.Topic != nil { + l = len(*m.Topic) + n += 1 + l + sovTrace(uint64(l)) } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) @@ -2740,11 +2917,9 @@ func (m *TraceEvent_DeliverMessage) Size() (n int) { l = len(m.MessageID) n += 1 + l + sovTrace(uint64(l)) } - if len(m.Topics) > 0 { - for _, s := range m.Topics { - l = len(s) - n += 1 + l + sovTrace(uint64(l)) - } + if m.Topic != nil { + l = len(*m.Topic) + n += 1 + l + sovTrace(uint64(l)) } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) @@ -2958,11 +3133,9 @@ func (m *TraceEvent_MessageMeta) Size() (n int) { l = len(m.MessageID) n += 1 + l + sovTrace(uint64(l)) } - if len(m.Topics) > 0 { - for _, s := range m.Topics { - l = len(s) - n += 1 + l + sovTrace(uint64(l)) - } + if m.Topic != nil { + l = len(*m.Topic) + n += 1 + l + sovTrace(uint64(l)) } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) @@ -3122,14 +3295,7 @@ func (m *TraceEventBatch) Size() (n int) { } func sovTrace(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } - } - return n + return (math_bits.Len64(x|1) + 6) / 7 } func sozTrace(x uint64) (n int) { return sovTrace(uint64((x << 1) ^ uint64((int64(x) >> 63)))) @@ -3795,7 +3961,7 @@ func (m *TraceEvent_PublishMessage) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Topics", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Topic", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3823,7 +3989,8 @@ func (m *TraceEvent_PublishMessage) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Topics = append(m.Topics, string(dAtA[iNdEx:postIndex])) + s := string(dAtA[iNdEx:postIndex]) + m.Topic = &s iNdEx = postIndex default: iNdEx = preIndex @@ -3982,7 +4149,7 @@ func (m *TraceEvent_RejectMessage) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Topics", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Topic", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4010,7 +4177,8 @@ func (m *TraceEvent_RejectMessage) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Topics = append(m.Topics, string(dAtA[iNdEx:postIndex])) + s := string(dAtA[iNdEx:postIndex]) + m.Topic = &s iNdEx = postIndex default: iNdEx = preIndex @@ -4136,7 +4304,7 @@ func (m *TraceEvent_DuplicateMessage) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Topics", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Topic", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4164,7 +4332,8 @@ func (m *TraceEvent_DuplicateMessage) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Topics = append(m.Topics, string(dAtA[iNdEx:postIndex])) + s := string(dAtA[iNdEx:postIndex]) + m.Topic = &s iNdEx = postIndex default: iNdEx = preIndex @@ -4256,7 +4425,7 @@ func (m *TraceEvent_DeliverMessage) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Topics", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Topic", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4284,7 +4453,8 @@ func (m *TraceEvent_DeliverMessage) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Topics = append(m.Topics, string(dAtA[iNdEx:postIndex])) + s := string(dAtA[iNdEx:postIndex]) + m.Topic = &s iNdEx = postIndex default: iNdEx = preIndex @@ -5531,7 +5701,7 @@ func (m *TraceEvent_MessageMeta) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Topics", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Topic", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5559,7 +5729,8 @@ func (m *TraceEvent_MessageMeta) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Topics = append(m.Topics, string(dAtA[iNdEx:postIndex])) + s := string(dAtA[iNdEx:postIndex]) + m.Topic = &s iNdEx = postIndex default: iNdEx = preIndex @@ -6386,6 +6557,7 @@ func (m *TraceEventBatch) Unmarshal(dAtA []byte) error { func skipTrace(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 { @@ -6417,10 +6589,8 @@ func skipTrace(dAtA []byte) (n int, err error) { break } } - return iNdEx, nil case 1: iNdEx += 8 - return iNdEx, nil case 2: var length int for shift := uint(0); ; shift += 7 { @@ -6441,55 +6611,30 @@ func skipTrace(dAtA []byte) (n int, err error) { return 0, ErrInvalidLengthTrace } iNdEx += length - if iNdEx < 0 { - return 0, ErrInvalidLengthTrace - } - return iNdEx, nil case 3: - for { - var innerWire uint64 - var start int = iNdEx - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTrace - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - innerWire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - innerWireType := int(innerWire & 0x7) - if innerWireType == 4 { - break - } - next, err := skipTrace(dAtA[start:]) - if err != nil { - return 0, err - } - iNdEx = start + next - if iNdEx < 0 { - return 0, ErrInvalidLengthTrace - } - } - return iNdEx, nil + depth++ case 4: - return iNdEx, nil + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTrace + } + depth-- case 5: iNdEx += 4 - return iNdEx, nil default: return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } + if iNdEx < 0 { + return 0, ErrInvalidLengthTrace + } + if depth == 0 { + return iNdEx, nil + } } - panic("unreachable") + return 0, io.ErrUnexpectedEOF } var ( - ErrInvalidLengthTrace = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTrace = fmt.Errorf("proto: integer overflow") + ErrInvalidLengthTrace = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTrace = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTrace = fmt.Errorf("proto: unexpected end of group") ) diff --git a/pb/trace.proto b/pb/trace.proto index 397f3c8d..d1aaef90 100644 --- a/pb/trace.proto +++ b/pb/trace.proto @@ -39,25 +39,25 @@ message TraceEvent { message PublishMessage { optional bytes messageID = 1; - repeated string topics = 2; + optional string topic = 2; } message RejectMessage { optional bytes messageID = 1; optional bytes receivedFrom = 2; optional string reason = 3; - repeated string topics = 4; + optional string topic = 4; } message DuplicateMessage { optional bytes messageID = 1; optional bytes receivedFrom = 2; - repeated string topics = 3; + optional string topic = 3; } message DeliverMessage { optional bytes messageID = 1; - repeated string topics = 2; + optional string topic = 2; } message AddPeer { @@ -110,7 +110,7 @@ message TraceEvent { message MessageMeta { optional bytes messageID = 1; - repeated string topics = 2; + optional string topic = 2; } message SubMeta { diff --git a/peer_gater.go b/peer_gater.go index 4f9b255b..f36c4fe7 100644 --- a/peer_gater.go +++ b/peer_gater.go @@ -396,10 +396,8 @@ func (pg *peerGater) DeliverMessage(msg *Message) { st := pg.getPeerStats(msg.ReceivedFrom) - weight := 0.0 - for _, topic := range msg.GetTopicIDs() { - weight += pg.params.TopicDeliveryWeights[topic] - } + topic := msg.GetTopic() + weight := pg.params.TopicDeliveryWeights[topic] if weight == 0 { weight = 1 diff --git a/pubsub.go b/pubsub.go index c2624dab..beb20120 100644 --- a/pubsub.go +++ b/pubsub.go @@ -834,14 +834,13 @@ func (p *PubSub) doAnnounceRetry(pid peer.ID, topic string, sub bool) { // notifySubs sends a given message to all corresponding subscribers. // Only called from processLoop. func (p *PubSub) notifySubs(msg *Message) { - for _, topic := range msg.GetTopicIDs() { - subs := p.mySubs[topic] - for f := range subs { - select { - case f.ch <- msg: - default: - log.Infof("Can't deliver message to subscription for topic %s; subscriber too slow", topic) - } + topic := msg.GetTopic() + subs := p.mySubs[topic] + for f := range subs { + select { + case f.ch <- msg: + default: + log.Infof("Can't deliver message to subscription for topic %s; subscriber too slow", topic) } } } @@ -873,12 +872,10 @@ func (p *PubSub) subscribedToMsg(msg *pb.Message) bool { return false } - for _, t := range msg.GetTopicIDs() { - if _, ok := p.mySubs[t]; ok { - return true - } - } - return false + topic := msg.GetTopic() + _, ok := p.mySubs[topic] + + return ok } // canRelayMsg returns whether we are able to relay for one of the topics @@ -888,12 +885,10 @@ func (p *PubSub) canRelayMsg(msg *pb.Message) bool { return false } - for _, t := range msg.GetTopicIDs() { - if relays := p.myRelays[t]; relays != 0 { - return true - } - } - return false + topic := msg.GetTopic() + relays := p.myRelays[topic] + + return relays > 0 } func (p *PubSub) notifyLeave(topic string, pid peer.ID) { diff --git a/randomsub.go b/randomsub.go index b98c9bbd..85e7d789 100644 --- a/randomsub.go +++ b/randomsub.go @@ -103,22 +103,21 @@ func (rs *RandomSubRouter) Publish(msg *Message) { rspeers := make(map[peer.ID]struct{}) src := peer.ID(msg.GetFrom()) - for _, topic := range msg.GetTopicIDs() { - tmap, ok := rs.p.topics[topic] - if !ok { + topic := msg.GetTopic() + tmap, ok := rs.p.topics[topic] + if !ok { + return + } + + for p := range tmap { + if p == from || p == src { continue } - for p := range tmap { - if p == from || p == src { - continue - } - - if rs.peers[p] == FloodSubID { - tosend[p] = struct{}{} - } else { - rspeers[p] = struct{}{} - } + if rs.peers[p] == FloodSubID { + tosend[p] = struct{}{} + } else { + rspeers[p] = struct{}{} } } diff --git a/score.go b/score.go index d2e54528..7979e24c 100644 --- a/score.go +++ b/score.go @@ -865,14 +865,13 @@ func (ps *peerScore) markInvalidMessageDelivery(p peer.ID, msg *Message) { return } - for _, topic := range msg.GetTopicIDs() { - tstats, ok := pstats.getTopicStats(topic, ps.params) - if !ok { - continue - } - - tstats.invalidMessageDeliveries += 1 + topic := msg.GetTopic() + tstats, ok := pstats.getTopicStats(topic, ps.params) + if !ok { + return } + + tstats.invalidMessageDeliveries += 1 } // markFirstMessageDelivery increments the "first message deliveries" counter @@ -884,27 +883,26 @@ func (ps *peerScore) markFirstMessageDelivery(p peer.ID, msg *Message) { return } - for _, topic := range msg.GetTopicIDs() { - tstats, ok := pstats.getTopicStats(topic, ps.params) - if !ok { - continue - } + topic := msg.GetTopic() + tstats, ok := pstats.getTopicStats(topic, ps.params) + if !ok { + return + } - cap := ps.params.Topics[topic].FirstMessageDeliveriesCap - tstats.firstMessageDeliveries += 1 - if tstats.firstMessageDeliveries > cap { - tstats.firstMessageDeliveries = cap - } + cap := ps.params.Topics[topic].FirstMessageDeliveriesCap + tstats.firstMessageDeliveries += 1 + if tstats.firstMessageDeliveries > cap { + tstats.firstMessageDeliveries = cap + } - if !tstats.inMesh { - continue - } + if !tstats.inMesh { + return + } - cap = ps.params.Topics[topic].MeshMessageDeliveriesCap - tstats.meshMessageDeliveries += 1 - if tstats.meshMessageDeliveries > cap { - tstats.meshMessageDeliveries = cap - } + cap = ps.params.Topics[topic].MeshMessageDeliveriesCap + tstats.meshMessageDeliveries += 1 + if tstats.meshMessageDeliveries > cap { + tstats.meshMessageDeliveries = cap } } @@ -912,41 +910,34 @@ func (ps *peerScore) markFirstMessageDelivery(p peer.ID, msg *Message) { // for messages we've seen before, as long the message was received within the // P3 window. func (ps *peerScore) markDuplicateMessageDelivery(p peer.ID, msg *Message, validated time.Time) { - var now time.Time - pstats, ok := ps.peerStats[p] if !ok { return } - if !validated.IsZero() { - now = time.Now() + topic := msg.GetTopic() + tstats, ok := pstats.getTopicStats(topic, ps.params) + if !ok { + return } - for _, topic := range msg.GetTopicIDs() { - tstats, ok := pstats.getTopicStats(topic, ps.params) - if !ok { - continue - } - - if !tstats.inMesh { - continue - } + if !tstats.inMesh { + return + } - tparams := ps.params.Topics[topic] + tparams := ps.params.Topics[topic] - // check against the mesh delivery window -- if the validated time is passed as 0, then - // the message was received before we finished validation and thus falls within the mesh - // delivery window. - if !validated.IsZero() && now.After(validated.Add(tparams.MeshMessageDeliveriesWindow)) { - continue - } + // check against the mesh delivery window -- if the validated time is passed as 0, then + // the message was received before we finished validation and thus falls within the mesh + // delivery window. + if !validated.IsZero() && time.Since(validated) > tparams.MeshMessageDeliveriesWindow { + return + } - cap := tparams.MeshMessageDeliveriesCap - tstats.meshMessageDeliveries += 1 - if tstats.meshMessageDeliveries > cap { - tstats.meshMessageDeliveries = cap - } + cap := tparams.MeshMessageDeliveriesCap + tstats.meshMessageDeliveries += 1 + if tstats.meshMessageDeliveries > cap { + tstats.meshMessageDeliveries = cap } } diff --git a/score_test.go b/score_test.go index fd53dfce..217983e3 100644 --- a/score_test.go +++ b/score_test.go @@ -108,7 +108,7 @@ func TestScoreFirstMessageDeliveries(t *testing.T) { nMessages := 100 for i := 0; i < nMessages; i++ { pbMsg := makeTestMessage(i) - pbMsg.TopicIDs = []string{mytopic} + pbMsg.Topic = &mytopic msg := Message{ReceivedFrom: peerA, Message: pbMsg} ps.ValidateMessage(&msg) ps.DeliverMessage(&msg) @@ -148,7 +148,7 @@ func TestScoreFirstMessageDeliveriesCap(t *testing.T) { nMessages := 100 for i := 0; i < nMessages; i++ { pbMsg := makeTestMessage(i) - pbMsg.TopicIDs = []string{mytopic} + pbMsg.Topic = &mytopic msg := Message{ReceivedFrom: peerA, Message: pbMsg} ps.ValidateMessage(&msg) ps.DeliverMessage(&msg) @@ -188,7 +188,7 @@ func TestScoreFirstMessageDeliveriesDecay(t *testing.T) { nMessages := 100 for i := 0; i < nMessages; i++ { pbMsg := makeTestMessage(i) - pbMsg.TopicIDs = []string{mytopic} + pbMsg.Topic = &mytopic msg := Message{ReceivedFrom: peerA, Message: pbMsg} ps.ValidateMessage(&msg) ps.DeliverMessage(&msg) @@ -268,7 +268,7 @@ func TestScoreMeshMessageDeliveries(t *testing.T) { wg := sync.WaitGroup{} for i := 0; i < nMessages; i++ { pbMsg := makeTestMessage(i) - pbMsg.TopicIDs = []string{mytopic} + pbMsg.Topic = &mytopic msg := Message{ReceivedFrom: peerA, Message: pbMsg} ps.ValidateMessage(&msg) ps.DeliverMessage(&msg) @@ -338,7 +338,7 @@ func TestScoreMeshMessageDeliveriesDecay(t *testing.T) { nMessages := 40 for i := 0; i < nMessages; i++ { pbMsg := makeTestMessage(i) - pbMsg.TopicIDs = []string{mytopic} + pbMsg.Topic = &mytopic msg := Message{ReceivedFrom: peerA, Message: pbMsg} ps.ValidateMessage(&msg) ps.DeliverMessage(&msg) @@ -412,7 +412,7 @@ func TestScoreMeshFailurePenalty(t *testing.T) { nMessages := 100 for i := 0; i < nMessages; i++ { pbMsg := makeTestMessage(i) - pbMsg.TopicIDs = []string{mytopic} + pbMsg.Topic = &mytopic msg := Message{ReceivedFrom: peerA, Message: pbMsg} ps.ValidateMessage(&msg) ps.DeliverMessage(&msg) @@ -472,7 +472,7 @@ func TestScoreInvalidMessageDeliveries(t *testing.T) { nMessages := 100 for i := 0; i < nMessages; i++ { pbMsg := makeTestMessage(i) - pbMsg.TopicIDs = []string{mytopic} + pbMsg.Topic = &mytopic msg := Message{ReceivedFrom: peerA, Message: pbMsg} ps.RejectMessage(&msg, rejectInvalidSignature) } @@ -509,7 +509,7 @@ func TestScoreInvalidMessageDeliveriesDecay(t *testing.T) { nMessages := 100 for i := 0; i < nMessages; i++ { pbMsg := makeTestMessage(i) - pbMsg.TopicIDs = []string{mytopic} + pbMsg.Topic = &mytopic msg := Message{ReceivedFrom: peerA, Message: pbMsg} ps.RejectMessage(&msg, rejectInvalidSignature) } @@ -555,7 +555,7 @@ func TestScoreRejectMessageDeliveries(t *testing.T) { ps.AddPeer(peerB, "myproto") pbMsg := makeTestMessage(0) - pbMsg.TopicIDs = []string{mytopic} + pbMsg.Topic = &mytopic msg := Message{ReceivedFrom: peerA, Message: pbMsg} msg2 := Message{ReceivedFrom: peerB, Message: pbMsg} @@ -887,7 +887,7 @@ func TestScoreRecapTopicParams(t *testing.T) { nMessages := 100 for i := 0; i < nMessages; i++ { pbMsg := makeTestMessage(i) - pbMsg.TopicIDs = []string{mytopic} + pbMsg.Topic = &mytopic msg := Message{ReceivedFrom: peerA, Message: pbMsg} ps.ValidateMessage(&msg) ps.DeliverMessage(&msg) @@ -969,7 +969,7 @@ func TestScoreResetTopicParams(t *testing.T) { nMessages := 100 for i := 0; i < nMessages; i++ { pbMsg := makeTestMessage(i) - pbMsg.TopicIDs = []string{mytopic} + pbMsg.Topic = &mytopic msg := Message{ReceivedFrom: peerA, Message: pbMsg} ps.ValidateMessage(&msg) ps.RejectMessage(&msg, rejectValidationFailed) diff --git a/sign_test.go b/sign_test.go index 413381cd..8ec791d0 100644 --- a/sign_test.go +++ b/sign_test.go @@ -28,11 +28,12 @@ func testSignVerify(t *testing.T, privk crypto.PrivKey) { if err != nil { t.Fatal(err) } + topic := "foo" m := pb.Message{ - Data: []byte("abc"), - TopicIDs: []string{"foo"}, - From: []byte(id), - Seqno: []byte("123"), + Data: []byte("abc"), + Topic: &topic, + From: []byte(id), + Seqno: []byte("123"), } signMessage(id, privk, &m) err = verifyMessageSignature(&m) diff --git a/tag_tracer.go b/tag_tracer.go index e2922e9f..a04472b5 100644 --- a/tag_tracer.go +++ b/tag_tracer.go @@ -151,11 +151,10 @@ func (t *tagTracer) bumpDeliveryTag(p peer.ID, topic string) error { } func (t *tagTracer) bumpTagsForMessage(p peer.ID, msg *Message) { - for _, topic := range msg.TopicIDs { - err := t.bumpDeliveryTag(p, topic) - if err != nil { - log.Warnf("error bumping delivery tag: %s", err) - } + topic := msg.GetTopic() + err := t.bumpDeliveryTag(p, topic) + if err != nil { + log.Warnf("error bumping delivery tag: %s", err) } } diff --git a/tag_tracer_test.go b/tag_tracer_test.go index 451d9f7c..eef8125f 100644 --- a/tag_tracer_test.go +++ b/tag_tracer_test.go @@ -88,16 +88,16 @@ func TestTagTracerDeliveryTags(t *testing.T) { for i := 0; i < 20; i++ { // deliver only 5 messages to topic 2 (less than the cap) - topics := []string{topic1} + topic := &topic1 if i < 5 { - topics = append(topics, topic2) + topic = &topic2 } msg := &Message{ ReceivedFrom: p, Message: &pb.Message{ - From: []byte(p), - Data: []byte("hello"), - TopicIDs: topics, + From: []byte(p), + Data: []byte("hello"), + Topic: topic, }, } tt.DeliverMessage(msg) @@ -175,14 +175,13 @@ func TestTagTracerDeliveryTagsNearFirst(t *testing.T) { tt.Join(topic) for i := 0; i < GossipSubConnTagMessageDeliveryCap+5; i++ { - topics := []string{topic} msg := &Message{ ReceivedFrom: p, Message: &pb.Message{ - From: []byte(p), - Data: []byte(fmt.Sprintf("msg-%d", i)), - TopicIDs: topics, - Seqno: []byte(fmt.Sprintf("%d", i)), + From: []byte(p), + Data: []byte(fmt.Sprintf("msg-%d", i)), + Topic: &topic, + Seqno: []byte(fmt.Sprintf("%d", i)), }, } diff --git a/topic.go b/topic.go index 72208f0a..91a1ff15 100644 --- a/topic.go +++ b/topic.go @@ -212,10 +212,10 @@ func (t *Topic) Publish(ctx context.Context, data []byte, opts ...PubOpt) error } m := &pb.Message{ - Data: data, - TopicIDs: []string{t.topic}, - From: nil, - Seqno: nil, + Data: data, + Topic: &t.topic, + From: nil, + Seqno: nil, } if t.p.signID != "" { m.From = []byte(t.p.signID) diff --git a/trace.go b/trace.go index df6740e2..febd9c19 100644 --- a/trace.go +++ b/trace.go @@ -53,7 +53,7 @@ func (t *pubsubTracer) PublishMessage(msg *Message) { Timestamp: &now, PublishMessage: &pb.TraceEvent_PublishMessage{ MessageID: []byte(t.msgID(msg.Message)), - Topics: msg.Message.TopicIDs, + Topic: msg.Message.Topic, }, } @@ -96,7 +96,7 @@ func (t *pubsubTracer) RejectMessage(msg *Message, reason string) { MessageID: []byte(t.msgID(msg.Message)), ReceivedFrom: []byte(msg.ReceivedFrom), Reason: &reason, - Topics: msg.TopicIDs, + Topic: msg.Topic, }, } @@ -126,7 +126,7 @@ func (t *pubsubTracer) DuplicateMessage(msg *Message) { DuplicateMessage: &pb.TraceEvent_DuplicateMessage{ MessageID: []byte(t.msgID(msg.Message)), ReceivedFrom: []byte(msg.ReceivedFrom), - Topics: msg.TopicIDs, + Topic: msg.Topic, }, } @@ -155,7 +155,7 @@ func (t *pubsubTracer) DeliverMessage(msg *Message) { Timestamp: &now, DeliverMessage: &pb.TraceEvent_DeliverMessage{ MessageID: []byte(t.msgID(msg.Message)), - Topics: msg.TopicIDs, + Topic: msg.Topic, }, } @@ -292,7 +292,7 @@ func (t *pubsubTracer) traceRPCMeta(rpc *RPC) *pb.TraceEvent_RPCMeta { for _, m := range rpc.Publish { msgs = append(msgs, &pb.TraceEvent_MessageMeta{ MessageID: []byte(t.msgID(m)), - Topics: m.TopicIDs, + Topic: m.Topic, }) } rpcMeta.Messages = msgs diff --git a/validation.go b/validation.go index 9359f87c..7b69ee34 100644 --- a/validation.go +++ b/validation.go @@ -211,18 +211,14 @@ func (v *validation) Push(src peer.ID, msg *Message) bool { // getValidators returns all validators that apply to a given message func (v *validation) getValidators(msg *Message) []*topicVal { - var vals []*topicVal + topic := msg.GetTopic() - for _, topic := range msg.GetTopicIDs() { - val, ok := v.topicVals[topic] - if !ok { - continue - } - - vals = append(vals, val) + val, ok := v.topicVals[topic] + if !ok { + return nil } - return vals + return []*topicVal{val} } // validateWorker is an active goroutine performing inline validation diff --git a/validation_test.go b/validation_test.go index 57896f60..ad3b2912 100644 --- a/validation_test.go +++ b/validation_test.go @@ -4,18 +4,11 @@ import ( "bytes" "context" "fmt" - "io" "sync" "testing" "time" - pb "github.com/libp2p/go-libp2p-pubsub/pb" - - "github.com/libp2p/go-libp2p-core/host" - "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" - - "github.com/libp2p/go-msgio/protoio" ) func TestRegisterUnregisterValidator(t *testing.T) { @@ -300,471 +293,3 @@ func TestValidateAssortedOptions(t *testing.T) { } } } - -func TestValidateMultitopic(t *testing.T) { - // this test adds coverage for multi-topic validation - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - hosts := getNetHosts(t, ctx, 3) - psubs := getPubsubs(ctx, hosts[1:], WithMessageSigning(false)) - for _, ps := range psubs { - err := ps.RegisterTopicValidator("test1", func(context.Context, peer.ID, *Message) bool { - return true - }) - if err != nil { - t.Fatal(err) - } - - err = ps.RegisterTopicValidator("test2", func(context.Context, peer.ID, *Message) bool { - return true - }) - if err != nil { - t.Fatal(err) - } - - err = ps.RegisterTopicValidator("test3", func(context.Context, peer.ID, *Message) bool { - return false - }) - if err != nil { - t.Fatal(err) - } - } - - publisher := &multiTopicPublisher{ctx: ctx, h: hosts[0]} - hosts[0].SetStreamHandler(FloodSubID, publisher.handleStream) - - connectAll(t, hosts) - - var subs1, subs2, subs3 []*Subscription - for _, ps := range psubs { - sub, err := ps.Subscribe("test1") - if err != nil { - t.Fatal(err) - } - subs1 = append(subs1, sub) - - sub, err = ps.Subscribe("test2") - if err != nil { - t.Fatal(err) - } - subs2 = append(subs2, sub) - - sub, err = ps.Subscribe("test3") - if err != nil { - t.Fatal(err) - } - subs3 = append(subs2, sub) - } - - time.Sleep(time.Second) - - msg1 := "i am a walrus" - - // this goes to test1 and test2, which is accepted and should be delivered - publisher.publish(msg1, "test1", "test2") - for _, sub := range subs1 { - assertReceive(t, sub, []byte(msg1)) - } - for _, sub := range subs2 { - assertReceive(t, sub, []byte(msg1)) - } - - // this goes to test2 and test3, which is rejected by the test3 validator and should not be delivered - msg2 := "i am not a walrus" - publisher.publish(msg2, "test2", "test3") - - expectNoMessage := func(sub *Subscription) { - ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) - defer cancel() - - m, err := sub.Next(ctx) - if err == nil { - t.Fatal("expected no message, but got ", string(m.Data)) - } - } - - for _, sub := range subs2 { - expectNoMessage(sub) - } - - for _, sub := range subs3 { - expectNoMessage(sub) - } -} - -func TestValidateMultitopicEx(t *testing.T) { - // this test adds coverage for multi-topic validation with extended validators - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - hosts := getNetHosts(t, ctx, 3) - psubs := getPubsubs(ctx, hosts[1:], WithMessageSigning(false)) - for _, ps := range psubs { - err := ps.RegisterTopicValidator("test1", func(context.Context, peer.ID, *Message) ValidationResult { - return ValidationAccept - }) - if err != nil { - t.Fatal(err) - } - - err = ps.RegisterTopicValidator("test2", func(context.Context, peer.ID, *Message) ValidationResult { - return ValidationAccept - }) - if err != nil { - t.Fatal(err) - } - - err = ps.RegisterTopicValidator("test3", func(context.Context, peer.ID, *Message) ValidationResult { - return ValidationIgnore - }) - if err != nil { - t.Fatal(err) - } - - err = ps.RegisterTopicValidator("test4", func(context.Context, peer.ID, *Message) ValidationResult { - return ValidationReject - }) - if err != nil { - t.Fatal(err) - } - - // this is a bogus validator that returns an invalid validation result; the system should interpret - // this as ValidationIgnore and not crash or do anything other than ignore the message - err = ps.RegisterTopicValidator("test5", func(context.Context, peer.ID, *Message) ValidationResult { - return ValidationResult(1234) - }) - if err != nil { - t.Fatal(err) - } - - } - - publisher := &multiTopicPublisher{ctx: ctx, h: hosts[0]} - hosts[0].SetStreamHandler(FloodSubID, publisher.handleStream) - - connectAll(t, hosts) - - var subs1, subs2, subs3, subs4, subs5 []*Subscription - for _, ps := range psubs { - sub, err := ps.Subscribe("test1") - if err != nil { - t.Fatal(err) - } - subs1 = append(subs1, sub) - - sub, err = ps.Subscribe("test2") - if err != nil { - t.Fatal(err) - } - subs2 = append(subs2, sub) - - sub, err = ps.Subscribe("test3") - if err != nil { - t.Fatal(err) - } - subs3 = append(subs3, sub) - - sub, err = ps.Subscribe("test4") - if err != nil { - t.Fatal(err) - } - subs4 = append(subs4, sub) - - sub, err = ps.Subscribe("test5") - if err != nil { - t.Fatal(err) - } - subs4 = append(subs5, sub) - - } - - time.Sleep(time.Second) - - msg1 := "i am a walrus" - - // this goes to test1 and test2, which is accepted and should be delivered - publisher.publish(msg1, "test1", "test2") - for _, sub := range subs1 { - assertReceive(t, sub, []byte(msg1)) - } - for _, sub := range subs2 { - assertReceive(t, sub, []byte(msg1)) - } - - // this goes to test2 and test3, which is ignored by the test3 validator and should not be delivered - msg2 := "i am not a walrus" - publisher.publish(msg2, "test2", "test3") - - expectNoMessage := func(sub *Subscription) { - ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) - defer cancel() - - m, err := sub.Next(ctx) - if err == nil { - t.Fatal("expected no message, but got ", string(m.Data)) - } - } - - for _, sub := range subs2 { - expectNoMessage(sub) - } - - for _, sub := range subs3 { - expectNoMessage(sub) - } - - // this goes to test2 and test4, which is rejected by the test4 validator and should not be delivered - publisher.publish(msg2, "test2", "test4") - - for _, sub := range subs2 { - expectNoMessage(sub) - } - - for _, sub := range subs4 { - expectNoMessage(sub) - } - - // this goes to test3 and test4, which is rejected by the test4 validator and should not be delivered - publisher.publish(msg2, "test3", "test4") - - for _, sub := range subs3 { - expectNoMessage(sub) - } - - for _, sub := range subs4 { - expectNoMessage(sub) - } - - // this goes to test1 and test5, which by virtue of its bogus validator should result on the message - // being ignored - publisher.publish(msg2, "test1", "test5") - - for _, sub := range subs1 { - expectNoMessage(sub) - } - - for _, sub := range subs5 { - expectNoMessage(sub) - } -} - -func TestValidateMultitopicEx2(t *testing.T) { - // like the previous test, but with all validators inline - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - hosts := getNetHosts(t, ctx, 3) - psubs := getPubsubs(ctx, hosts[1:], WithMessageSigning(false)) - for _, ps := range psubs { - err := ps.RegisterTopicValidator("test1", func(context.Context, peer.ID, *Message) ValidationResult { - return ValidationAccept - }, - WithValidatorInline(true)) - if err != nil { - t.Fatal(err) - } - - err = ps.RegisterTopicValidator("test2", func(context.Context, peer.ID, *Message) ValidationResult { - return ValidationAccept - }, - WithValidatorInline(true)) - if err != nil { - t.Fatal(err) - } - - err = ps.RegisterTopicValidator("test3", func(context.Context, peer.ID, *Message) ValidationResult { - return ValidationIgnore - }, - WithValidatorInline(true)) - if err != nil { - t.Fatal(err) - } - - err = ps.RegisterTopicValidator("test4", func(context.Context, peer.ID, *Message) ValidationResult { - return ValidationReject - }, - WithValidatorInline(true)) - if err != nil { - t.Fatal(err) - } - - // this is a bogus validator that returns an invalid validation result; the system should interpret - // this as ValidationIgnore and not crash or do anything other than ignore the message - err = ps.RegisterTopicValidator("test5", func(context.Context, peer.ID, *Message) ValidationResult { - return ValidationResult(1234) - }, - WithValidatorInline(true)) - if err != nil { - t.Fatal(err) - } - - } - - publisher := &multiTopicPublisher{ctx: ctx, h: hosts[0]} - hosts[0].SetStreamHandler(FloodSubID, publisher.handleStream) - - connectAll(t, hosts) - - var subs1, subs2, subs3, subs4, subs5 []*Subscription - for _, ps := range psubs { - sub, err := ps.Subscribe("test1") - if err != nil { - t.Fatal(err) - } - subs1 = append(subs1, sub) - - sub, err = ps.Subscribe("test2") - if err != nil { - t.Fatal(err) - } - subs2 = append(subs2, sub) - - sub, err = ps.Subscribe("test3") - if err != nil { - t.Fatal(err) - } - subs3 = append(subs3, sub) - - sub, err = ps.Subscribe("test4") - if err != nil { - t.Fatal(err) - } - subs4 = append(subs4, sub) - - sub, err = ps.Subscribe("test5") - if err != nil { - t.Fatal(err) - } - subs4 = append(subs5, sub) - - } - - time.Sleep(time.Second) - - msg1 := "i am a walrus" - - // this goes to test1 and test2, which is accepted and should be delivered - publisher.publish(msg1, "test1", "test2") - for _, sub := range subs1 { - assertReceive(t, sub, []byte(msg1)) - } - for _, sub := range subs2 { - assertReceive(t, sub, []byte(msg1)) - } - - // this goes to test2 and test3, which is ignored by the test3 validator and should not be delivered - msg2 := "i am not a walrus" - publisher.publish(msg2, "test2", "test3") - - expectNoMessage := func(sub *Subscription) { - ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) - defer cancel() - - m, err := sub.Next(ctx) - if err == nil { - t.Fatal("expected no message, but got ", string(m.Data)) - } - } - - for _, sub := range subs2 { - expectNoMessage(sub) - } - - for _, sub := range subs3 { - expectNoMessage(sub) - } - - // this goes to test2 and test4, which is rejected by the test4 validator and should not be delivered - publisher.publish(msg2, "test2", "test4") - - for _, sub := range subs2 { - expectNoMessage(sub) - } - - for _, sub := range subs4 { - expectNoMessage(sub) - } - - // this goes to test3 and test4, which is rejected by the test4 validator and should not be delivered - publisher.publish(msg2, "test3", "test4") - - for _, sub := range subs3 { - expectNoMessage(sub) - } - - for _, sub := range subs4 { - expectNoMessage(sub) - } - - // this goes to test1 and test5, which by virtue of its bogus validator should result on the message - // being ignored - publisher.publish(msg2, "test1", "test5") - - for _, sub := range subs1 { - expectNoMessage(sub) - } - - for _, sub := range subs5 { - expectNoMessage(sub) - } -} - -type multiTopicPublisher struct { - ctx context.Context - h host.Host - - mx sync.Mutex - out []network.Stream - mcount int -} - -func (p *multiTopicPublisher) handleStream(s network.Stream) { - defer s.Close() - - os, err := p.h.NewStream(p.ctx, s.Conn().RemotePeer(), FloodSubID) - if err != nil { - panic(err) - } - - p.mx.Lock() - p.out = append(p.out, os) - p.mx.Unlock() - - r := protoio.NewDelimitedReader(s, 1<<20) - var rpc pb.RPC - for { - rpc.Reset() - err = r.ReadMsg(&rpc) - if err != nil { - if err != io.EOF { - s.Reset() - } - return - } - } -} - -func (p *multiTopicPublisher) publish(msg string, topics ...string) { - p.mcount++ - rpc := &pb.RPC{ - Publish: []*pb.Message{ - &pb.Message{ - From: []byte(p.h.ID()), - Data: []byte(msg), - Seqno: []byte{byte(p.mcount)}, - TopicIDs: topics, - }, - }, - } - - p.mx.Lock() - defer p.mx.Unlock() - for _, os := range p.out { - w := protoio.NewDelimitedWriter(os) - err := w.WriteMsg(rpc) - if err != nil { - panic(err) - } - } -}