good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
f1537b77
Commit
f1537b77
authored
Feb 19, 2019
by
Matthew Halpern
Committed by
Felix Lange
Feb 19, 2019
Browse files
Options
Downloads
Patches
Plain Diff
p2p/discover: make maximum packet size a constant (#19061)
parent
bf42535d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
p2p/discover/udp.go
+9
-7
9 additions, 7 deletions
p2p/discover/udp.go
with
9 additions
and
7 deletions
p2p/discover/udp.go
+
9
−
7
View file @
f1537b77
...
...
@@ -54,6 +54,11 @@ const (
ntpFailureThreshold
=
32
// Continuous timeouts after which to check NTP
ntpWarningCooldown
=
10
*
time
.
Minute
// Minimum amount of time to pass before repeating NTP warning
driftThreshold
=
10
*
time
.
Second
// Allowed clock drift before warning user
// Discovery packets are defined to be no larger than 1280 bytes.
// Packets larger than this size will be cut at the end and treated
// as invalid because their hash won't match.
maxPacketSize
=
1280
)
// RPC packet types
...
...
@@ -496,7 +501,7 @@ var (
headSpace
=
make
([]
byte
,
headSize
)
// Neighbors replies are sent across multiple packets to
// stay below the
1280 byt
e limit. We compute the maximum number
// stay below the
packet siz
e limit. We compute the maximum number
// of entries by stuffing a packet until it grows too large.
maxNeighbors
int
)
...
...
@@ -511,7 +516,7 @@ func init() {
// If this ever happens, it will be caught by the unit tests.
panic
(
"cannot encode: "
+
err
.
Error
())
}
if
headSize
+
size
+
1
>=
1280
{
if
headSize
+
size
+
1
>=
maxPacketSize
{
maxNeighbors
=
n
break
}
...
...
@@ -562,10 +567,7 @@ func (t *udp) readLoop(unhandled chan<- ReadPacket) {
defer
close
(
unhandled
)
}
// Discovery packets are defined to be no larger than 1280 bytes.
// Packets larger than this size will be cut at the end and treated
// as invalid because their hash won't match.
buf
:=
make
([]
byte
,
1280
)
buf
:=
make
([]
byte
,
maxPacketSize
)
for
{
nbytes
,
from
,
err
:=
t
.
conn
.
ReadFromUDP
(
buf
)
if
netutil
.
IsTemporaryError
(
err
)
{
...
...
@@ -715,7 +717,7 @@ func (req *findnode) handle(t *udp, from *net.UDPAddr, fromID enode.ID, mac []by
t
.
tab
.
mutex
.
Unlock
()
// Send neighbors in chunks with at most maxNeighbors per packet
// to stay below the
1280 byt
e limit.
// to stay below the
packet siz
e limit.
p
:=
neighbors
{
Expiration
:
uint64
(
time
.
Now
()
.
Add
(
expiration
)
.
Unix
())}
var
sent
bool
for
_
,
n
:=
range
closest
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment