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
6830ddb6
Commit
6830ddb6
authored
Apr 18, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
downloader: free up peers from work when the downloader resets
parent
7c5d50f6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
5 deletions
+22
-5
downloader.go
eth/downloader/downloader.go
+3
-1
peer.go
eth/downloader/peer.go
+10
-0
queue.go
eth/downloader/queue.go
+9
-4
No files found.
eth/downloader/downloader.go
View file @
6830ddb6
...
...
@@ -297,8 +297,9 @@ out:
// make sure that we have peers available for fetching. If all peers have been tried
// and all failed throw an error
if
len
(
availablePeers
)
>
0
&&
d
.
queue
.
fetchPool
.
Size
(
)
==
0
{
if
len
(
d
.
queue
.
fetching
)
==
0
{
d
.
queue
.
reset
()
d
.
peers
.
reset
()
return
errPeersUnavailable
}
...
...
@@ -337,6 +338,7 @@ out:
d
.
queue
.
deliver
(
pid
,
nil
)
if
peer
:=
d
.
peers
[
pid
];
peer
!=
nil
{
peer
.
demote
()
peer
.
reset
()
}
}
...
...
eth/downloader/peer.go
View file @
6830ddb6
...
...
@@ -20,6 +20,12 @@ type blockFetcherFn func([]common.Hash) error
// XXX make threadsafe!!!!
type
peers
map
[
string
]
*
peer
func
(
p
peers
)
reset
()
{
for
_
,
peer
:=
range
p
{
p
.
reset
()
}
}
func
(
p
peers
)
get
(
state
int
)
[]
*
peer
{
var
peers
[]
*
peer
for
_
,
peer
:=
range
p
{
...
...
@@ -128,3 +134,7 @@ func (p *peer) demote() {
p
.
rep
=
0
}
}
func
(
p
*
peer
)
reset
()
{
p
.
state
=
idleState
}
eth/downloader/queue.go
View file @
6830ddb6
...
...
@@ -60,13 +60,18 @@ func (c *queue) get(p *peer, max int) *chunk {
return
false
}
hashes
.
Add
(
v
)
i
++
// Skip any hashes that have previously been requested from the peer
if
!
p
.
requested
.
Has
(
v
)
{
hashes
.
Add
(
v
)
i
++
}
return
true
})
// remove hashes that have previously been fetched
hashes
.
Separate
(
p
.
requested
)
// if no hashes can be requested return a nil chunk
if
hashes
.
Size
()
==
0
{
return
nil
}
// remove the fetchable hashes from hash pool
c
.
hashPool
.
Separate
(
hashes
)
...
...
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