#388 Remove support for multi-topic messages

Merged vyzo vyzo

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.


@@ -151,11 +151,10 @@
Loading
151 151
}
152 152
153 153
func (t *tagTracer) bumpTagsForMessage(p peer.ID, msg *Message) {
154 -
	for _, topic := range msg.TopicIDs {
155 -
		err := t.bumpDeliveryTag(p, topic)
156 -
		if err != nil {
157 -
			log.Warnf("error bumping delivery tag: %s", err)
158 -
		}
154 +
	topic := msg.GetTopic()
155 +
	err := t.bumpDeliveryTag(p, topic)
156 +
	if err != nil {
157 +
		log.Warnf("error bumping delivery tag: %s", err)
159 158
	}
160 159
}
161 160

@@ -75,21 +75,10 @@
Loading
75 75
76 76
func (fs *FloodSubRouter) Publish(msg *Message) {
77 77
	from := msg.ReceivedFrom
78 -
79 -
	tosend := make(map[peer.ID]struct{})
80 -
	for _, topic := range msg.GetTopicIDs() {
81 -
		tmap, ok := fs.p.topics[topic]
82 -
		if !ok {
83 -
			continue
84 -
		}
85 -
86 -
		for p := range tmap {
87 -
			tosend[p] = struct{}{}
88 -
		}
89 -
	}
78 +
	topic := msg.GetTopic()
90 79
91 80
	out := rpcWithMessages(msg.Message)
92 -
	for pid := range tosend {
81 +
	for pid := range fs.p.topics[topic] {
93 82
		if pid == from || pid == peer.ID(msg.GetFrom()) {
94 83
			continue
95 84
		}

@@ -48,14 +48,14 @@
Loading
48 48
}
49 49
50 50
type CacheEntry struct {
51 -
	mid    string
52 -
	topics []string
51 +
	mid   string
52 +
	topic string
53 53
}
54 54
55 55
func (mc *MessageCache) Put(msg *pb.Message) {
56 56
	mid := mc.msgID(msg)
57 57
	mc.msgs[mid] = msg
58 -
	mc.history[0] = append(mc.history[0], CacheEntry{mid: mid, topics: msg.GetTopicIDs()})
58 +
	mc.history[0] = append(mc.history[0], CacheEntry{mid: mid, topic: msg.GetTopic()})
59 59
}
60 60
61 61
func (mc *MessageCache) Get(mid string) (*pb.Message, bool) {
@@ -83,11 +83,8 @@
Loading
83 83
	var mids []string
84 84
	for _, entries := range mc.history[:mc.gossip] {
85 85
		for _, entry := range entries {
86 -
			for _, t := range entry.topics {
87 -
				if t == topic {
88 -
					mids = append(mids, entry.mid)
89 -
					break
90 -
				}
86 +
			if entry.topic == topic {
87 +
				mids = append(mids, entry.mid)
91 88
			}
92 89
		}
93 90
	}

@@ -396,10 +396,8 @@
Loading
396 396
397 397
	st := pg.getPeerStats(msg.ReceivedFrom)
398 398
399 -
	weight := 0.0
400 -
	for _, topic := range msg.GetTopicIDs() {
401 -
		weight += pg.params.TopicDeliveryWeights[topic]
402 -
	}
399 +
	topic := msg.GetTopic()
400 +
	weight := pg.params.TopicDeliveryWeights[topic]
403 401
404 402
	if weight == 0 {
405 403
		weight = 1

@@ -211,18 +211,14 @@
Loading
211 211
212 212
// getValidators returns all validators that apply to a given message
213 213
func (v *validation) getValidators(msg *Message) []*topicVal {
214 -
	var vals []*topicVal
214 +
	topic := msg.GetTopic()
215 215
216 -
	for _, topic := range msg.GetTopicIDs() {
217 -
		val, ok := v.topicVals[topic]
218 -
		if !ok {
219 -
			continue
220 -
		}
221 -
222 -
		vals = append(vals, val)
216 +
	val, ok := v.topicVals[topic]
217 +
	if !ok {
218 +
		return nil
223 219
	}
224 220
225 -
	return vals
221 +
	return []*topicVal{val}
226 222
}
227 223
228 224
// validateWorker is an active goroutine performing inline validation

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Click to load this diff.
Loading diff...

Learn more Showing 20 files with coverage changes found.

Changes in validation.go
-61
+2
+35
Loading file...
Changes in notify.go
-5
-1
Loading file...
Changes in sign.go
-6
Loading file...
Changes in blacklist.go
-6
Loading file...
Changes in tracer.go
-19
Loading file...
Changes in discovery.go
-19
-3
Loading file...
Changes in floodsub.go
-10
Loading file...
Changes in tag_tracer.go
-21
Loading file...
Changes in mcache.go
-7
Loading file...
Changes in peer_gater.go
-16
-6
Loading file...
Changes in topic.go
-21
-2
-1
Loading file...
Changes in gossip_tracer.go
-12
Loading file...
Changes in gossipsub.go
-118
-3
-5
Loading file...
Changes in score.go
-43
-4
-4
Loading file...
Changes in pubsub.go
-50
-1
-6
Loading file...
Changes in randomsub.go
-11
-3
Loading file...
Changes in trace.go
-32
-3
Loading file...
Changes in score_params.go
-6
Loading file...
Changes in comm.go
-11
-2
-1
Loading file...
Changes in subscription.go
-3
-1
Loading file...
Files Coverage
blacklist.go -3.07% 88.24%
comm.go +1.97% 93.48%
discovery.go -2.65% 65.99%
floodsub.go -4.85% 85.71%
gossip_tracer.go -0.99% 93.06%
gossipsub.go -0.97% 87.05%
mcache.go -3.25% 88.24%
notify.go -5.00% 75.00%
peer_gater.go -0.60% 59.89%
pubsub.go -0.63% 79.80%
randomsub.go -0.83% 75.36%
score.go -1.05% 76.09%
score_params.go -0.21% 97.26%
sign.go -4.95% 52.94%
subscription.go +2.08% 83.33%
tag_tracer.go -2.20% 87.88%
topic.go -1.41% 76.36%
trace.go -0.49% 87.80%
tracer.go -2.92% 78.51%
validation.go -18.36% 71.76%
Project Totals (20 files) 80.13%
Loading