Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-pubsub
Commits
235c28ff
Commit
235c28ff
authored
Apr 20, 2020
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
truncate per peer message id lists
parent
8bc2c5c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
gossipsub.go
gossipsub.go
+12
-3
No files found.
gossipsub.go
View file @
235c28ff
...
@@ -1194,8 +1194,8 @@ func (gs *GossipSubRouter) emitGossip(topic string, exclude map[peer.ID]struct{}
...
@@ -1194,8 +1194,8 @@ func (gs *GossipSubRouter) emitGossip(topic string, exclude map[peer.ID]struct{}
// if we are emitting more than GossipSubMaxIHaveLength mids, truncate the list
// if we are emitting more than GossipSubMaxIHaveLength mids, truncate the list
if
len
(
mids
)
>
GossipSubMaxIHaveLength
{
if
len
(
mids
)
>
GossipSubMaxIHaveLength
{
log
.
Debugf
(
"too many messages for gossip; truncating IHAVE list (%d messages)"
,
len
(
mids
))
// we do the truncation (with shuffling) per peer below
mids
=
mids
[
:
GossipSubMaxIHaveLength
]
log
.
Debugf
(
"too many messages for gossip; will truncate IHAVE list (%d messages)"
,
len
(
mids
))
}
}
// Send gossip to GossipFactor peers above threshold, with a minimum of D_lazy.
// Send gossip to GossipFactor peers above threshold, with a minimum of D_lazy.
...
@@ -1226,7 +1226,16 @@ func (gs *GossipSubRouter) emitGossip(topic string, exclude map[peer.ID]struct{}
...
@@ -1226,7 +1226,16 @@ func (gs *GossipSubRouter) emitGossip(topic string, exclude map[peer.ID]struct{}
// Emit the IHAVE gossip to the selected peers.
// Emit the IHAVE gossip to the selected peers.
for
_
,
p
:=
range
peers
{
for
_
,
p
:=
range
peers
{
gs
.
enqueueGossip
(
p
,
&
pb
.
ControlIHave
{
TopicID
:
&
topic
,
MessageIDs
:
mids
})
peerMids
:=
mids
if
len
(
mids
)
>
GossipSubMaxIHaveLength
{
// we do this per peer so that we emit a different set for each peer.
// we have enough redundancy in the system that this will significantly increase the message
// coverage when we do truncate.
peerMids
=
make
([]
string
,
GossipSubMaxIHaveLength
)
shuffleStrings
(
mids
)
copy
(
peerMids
,
mids
)
}
gs
.
enqueueGossip
(
p
,
&
pb
.
ControlIHave
{
TopicID
:
&
topic
,
MessageIDs
:
peerMids
})
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment