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
3ec159ab
Commit
3ec159ab
authored
Jun 03, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/downloader: demote peers if they exceed the soft limits at 1 blocks already
parent
c9a546c3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
peer.go
eth/downloader/peer.go
+8
-3
No files found.
eth/downloader/peer.go
View file @
3ec159ab
...
@@ -93,11 +93,16 @@ func (p *peer) SetIdle() {
...
@@ -93,11 +93,16 @@ func (p *peer) SetIdle() {
// Calculate the new download bandwidth allowance
// Calculate the new download bandwidth allowance
prev
:=
atomic
.
LoadInt32
(
&
p
.
capacity
)
prev
:=
atomic
.
LoadInt32
(
&
p
.
capacity
)
next
:=
int32
(
math
.
Max
(
1
,
math
.
Min
(
MaxBlockFetch
,
float64
(
prev
)
*
scale
)))
next
:=
int32
(
math
.
Max
(
1
,
math
.
Min
(
MaxBlockFetch
,
float64
(
prev
)
*
scale
)))
if
scale
<
1
{
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"%s: reducing block allowance from %d to %d"
,
p
.
id
,
prev
,
next
)
}
// Try to update the old value
// Try to update the old value
if
atomic
.
CompareAndSwapInt32
(
&
p
.
capacity
,
prev
,
next
)
{
if
atomic
.
CompareAndSwapInt32
(
&
p
.
capacity
,
prev
,
next
)
{
// If we're having problems at 1 capacity, try to find better peers
if
next
==
1
{
p
.
Demote
()
}
if
prev
!=
next
{
glog
.
V
(
logger
.
Detail
)
.
Infof
(
"%s: changing block download capacity from %d to %d"
,
p
.
id
,
prev
,
next
)
}
break
break
}
}
}
}
...
...
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