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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
ebbd8b07
Commit
ebbd8b07
authored
9 years ago
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
eth/downloader: revert to demotion, use harsher penalty
parent
685862d2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
eth/downloader/downloader.go
+9
-3
9 additions, 3 deletions
eth/downloader/downloader.go
eth/downloader/peer.go
+10
-5
10 additions, 5 deletions
eth/downloader/peer.go
with
19 additions
and
8 deletions
eth/downloader/downloader.go
+
9
−
3
View file @
ebbd8b07
...
...
@@ -335,7 +335,7 @@ out:
// Deliver the received chunk of blocks, but drop the peer if invalid
if
err
:=
d
.
queue
.
Deliver
(
blockPack
.
peerId
,
blockPack
.
blocks
);
err
!=
nil
{
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Failed delivery for peer %s: %v
\n
"
,
blockPack
.
peerId
,
err
)
d
.
peer
s
.
Unregister
(
blockPack
.
peerId
)
peer
.
Demote
(
)
break
}
if
glog
.
V
(
logger
.
Debug
)
{
...
...
@@ -358,7 +358,9 @@ out:
// 1) Time for them to respond;
// 2) Measure their speed;
// 3) Amount and availability.
d
.
peers
.
Unregister
(
pid
)
if
peer
:=
d
.
peers
.
Peer
(
pid
);
peer
!=
nil
{
peer
.
Demote
()
}
}
// After removing bad peers make sure we actually have sufficient peer left to keep downloading
if
d
.
peers
.
Peers
()
==
0
{
...
...
@@ -372,9 +374,13 @@ out:
if
d
.
queue
.
Throttle
()
{
continue
}
// Send a download request to all idle peers
// Send a download request to all idle peers
, until throttled
idlePeers
:=
d
.
peers
.
IdlePeers
()
for
_
,
peer
:=
range
idlePeers
{
// Short circuit if throttling activated since above
if
d
.
queue
.
Throttle
()
{
break
}
// Get a possible chunk. If nil is returned no chunk
// could be returned due to no hashes available.
request
:=
d
.
queue
.
Reserve
(
peer
,
maxBlockFetch
)
...
...
This diff is collapsed.
Click to expand it.
eth/downloader/peer.go
+
10
−
5
View file @
ebbd8b07
...
...
@@ -86,10 +86,8 @@ func (p *peer) Demote() {
for
{
// Calculate the new reputation value
prev
:=
atomic
.
LoadInt32
(
&
p
.
rep
)
next
:=
prev
-
2
if
next
<
0
{
next
=
0
}
next
:=
prev
/
2
// Try to update the old value
if
atomic
.
CompareAndSwapInt32
(
&
p
.
rep
,
prev
,
next
)
{
return
...
...
@@ -177,7 +175,7 @@ func (ps *peerSet) AllPeers() []*peer {
}
// IdlePeers retrieves a flat list of all the currently idle peers within the
// active peer set.
// active peer set
, ordered by their reputation
.
func
(
ps
*
peerSet
)
IdlePeers
()
[]
*
peer
{
ps
.
lock
.
RLock
()
defer
ps
.
lock
.
RUnlock
()
...
...
@@ -188,5 +186,12 @@ func (ps *peerSet) IdlePeers() []*peer {
list
=
append
(
list
,
p
)
}
}
for
i
:=
0
;
i
<
len
(
list
);
i
++
{
for
j
:=
i
+
1
;
j
<
len
(
list
);
j
++
{
if
atomic
.
LoadInt32
(
&
list
[
i
]
.
rep
)
<
atomic
.
LoadInt32
(
&
list
[
j
]
.
rep
)
{
list
[
i
],
list
[
j
]
=
list
[
j
],
list
[
i
]
}
}
}
return
list
}
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