Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
4cb1fca4
Unverified
Commit
4cb1fca4
authored
Nov 08, 2022
by
zhiqiangxu
Committed by
GitHub
Nov 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p/enode: implement per-source timeout in FairMix (#25962)
Co-authored-by:
Felix Lange
<
fjl@twurst.com
>
parent
53b624b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
iter.go
p2p/enode/iter.go
+14
-7
No files found.
p2p/enode/iter.go
View file @
4cb1fca4
...
...
@@ -203,27 +203,34 @@ func (m *FairMix) Close() {
func
(
m
*
FairMix
)
Next
()
bool
{
m
.
cur
=
nil
var
timeout
<-
chan
time
.
Time
if
m
.
timeout
>=
0
{
timer
:=
time
.
NewTimer
(
m
.
timeout
)
timeout
=
timer
.
C
defer
timer
.
Stop
()
}
for
{
source
:=
m
.
pickSource
()
if
source
==
nil
{
return
m
.
nextFromAny
()
}
var
timeout
<-
chan
time
.
Time
if
source
.
timeout
>=
0
{
timer
:=
time
.
NewTimer
(
source
.
timeout
)
timeout
=
timer
.
C
defer
timer
.
Stop
()
}
select
{
case
n
,
ok
:=
<-
source
.
next
:
if
ok
{
m
.
cur
=
n
// Here, the timeout is reset to the configured value
// because the source delivered a node.
source
.
timeout
=
m
.
timeout
m
.
cur
=
n
return
true
}
// This source has ended.
m
.
deleteSource
(
source
)
case
<-
timeout
:
// The selected source did not deliver a node within the timeout, so the
// timeout duration is halved for next time. This is supposed to improve
// latency with stuck sources.
source
.
timeout
/=
2
return
m
.
nextFromAny
()
}
...
...
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