Skip to content

Commit 237d418

Browse files
committed
Add documentation for the RequestPartialMessages topic option
and fix a bug where we would skip sending them full messages if they requested partial messages and we disabled partial messages.
1 parent a0a57bb commit 237d418

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

gossipsub.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,8 +1375,8 @@ func (gs *GossipSubRouter) rpcs(msg *Message) iter.Seq2[peer.ID, *RPC] {
13751375
if pid == from || pid == peer.ID(msg.GetFrom()) {
13761376
continue
13771377
}
1378-
if peerStates, ok := gs.p.topics[topic]; ok && peerStates[pid].requestsPartial {
1379-
// The peer requested partial messages. We'll skip sending them full messages
1378+
if peerStates, ok := gs.p.topics[topic]; ok && gs.extensions.myExtensions.PartialMessages && peerStates[pid].requestsPartial {
1379+
// We support partial messages and the peer requested partial messages. We'll skip sending them full messages
13801380
continue
13811381
}
13821382

pubsub.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,8 +1543,21 @@ type TopicOptions struct {
15431543

15441544
// RequestPartialMessages requests that peers, if they support it, send us
15451545
// partial messages on this topic.
1546+
//
1547+
// If a peer does not support partial messages, this has no effect, and the peer
1548+
// will continue sending us full messages
1549+
//
1550+
// It is an error to use this option if partial messages are not enabled
15461551
func RequestPartialMessages() TopicOpt {
15471552
return func(t *Topic) error {
1553+
gs, ok := t.p.rt.(*GossipSubRouter)
1554+
if !ok {
1555+
return errors.New("partial messages only supported by gossipsub")
1556+
}
1557+
1558+
if !gs.extensions.myExtensions.PartialMessages {
1559+
return errors.New("partial messages are not enabled")
1560+
}
15481561
t.requestPartialMessages = true
15491562
return nil
15501563
}

0 commit comments

Comments
 (0)