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
5c59d955
Commit
5c59d955
authored
Apr 18, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
downloader: defer peer reset after download
parent
86ecdcd5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
+8
-4
downloader.go
eth/downloader/downloader.go
+7
-4
peer.go
eth/downloader/peer.go
+1
-0
No files found.
eth/downloader/downloader.go
View file @
5c59d955
...
@@ -205,13 +205,13 @@ func (d *Downloader) startFetchingHashes(p *peer, hash common.Hash, ignoreInitia
...
@@ -205,13 +205,13 @@ func (d *Downloader) startFetchingHashes(p *peer, hash common.Hash, ignoreInitia
// Get the first batch of hashes
// Get the first batch of hashes
p
.
getHashes
(
hash
)
p
.
getHashes
(
hash
)
failureResponse
:=
time
.
NewTimer
(
hashTtl
)
failureResponse
Timer
:=
time
.
NewTimer
(
hashTtl
)
out
:
out
:
for
{
for
{
select
{
select
{
case
hashes
:=
<-
d
.
hashCh
:
case
hashes
:=
<-
d
.
hashCh
:
failureResponse
.
Reset
(
hashTtl
)
failureResponse
Timer
.
Reset
(
hashTtl
)
var
done
bool
// determines whether we're done fetching hashes (i.e. common hash found)
var
done
bool
// determines whether we're done fetching hashes (i.e. common hash found)
hashSet
:=
set
.
New
()
hashSet
:=
set
.
New
()
...
@@ -239,7 +239,7 @@ out:
...
@@ -239,7 +239,7 @@ out:
}
else
{
// we're done
}
else
{
// we're done
break
out
break
out
}
}
case
<-
failureResponse
.
C
:
case
<-
failureResponse
Timer
.
C
:
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Peer (%s) didn't respond in time for hash request
\n
"
,
p
.
id
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Peer (%s) didn't respond in time for hash request
\n
"
,
p
.
id
)
// TODO instead of reseting the queue select a new peer from which we can start downloading hashes.
// TODO instead of reseting the queue select a new peer from which we can start downloading hashes.
// 1. check for peer's best hash to be included in the current hash set;
// 1. check for peer's best hash to be included in the current hash set;
...
@@ -258,6 +258,10 @@ func (d *Downloader) startFetchingBlocks(p *peer) error {
...
@@ -258,6 +258,10 @@ func (d *Downloader) startFetchingBlocks(p *peer) error {
glog
.
V
(
logger
.
Detail
)
.
Infoln
(
"Downloading"
,
d
.
queue
.
hashPool
.
Size
(),
"block(s)"
)
glog
.
V
(
logger
.
Detail
)
.
Infoln
(
"Downloading"
,
d
.
queue
.
hashPool
.
Size
(),
"block(s)"
)
atomic
.
StoreInt32
(
&
d
.
downloadingBlocks
,
1
)
atomic
.
StoreInt32
(
&
d
.
downloadingBlocks
,
1
)
defer
atomic
.
StoreInt32
(
&
d
.
downloadingBlocks
,
0
)
defer
atomic
.
StoreInt32
(
&
d
.
downloadingBlocks
,
0
)
// Defer the peer reset. This will empty the peer requested set
// and makes sure there are no lingering peers with an incorrect
// state
defer
d
.
peers
.
reset
()
start
:=
time
.
Now
()
start
:=
time
.
Now
()
...
@@ -302,7 +306,6 @@ out:
...
@@ -302,7 +306,6 @@ out:
// and all failed throw an error
// and all failed throw an error
if
len
(
d
.
queue
.
fetching
)
==
0
{
if
len
(
d
.
queue
.
fetching
)
==
0
{
d
.
queue
.
reset
()
d
.
queue
.
reset
()
d
.
peers
.
reset
()
return
fmt
.
Errorf
(
"%v avaialable = %d. total = %d"
,
errPeersUnavailable
,
len
(
availablePeers
),
len
(
d
.
peers
))
return
fmt
.
Errorf
(
"%v avaialable = %d. total = %d"
,
errPeersUnavailable
,
len
(
availablePeers
),
len
(
d
.
peers
))
}
}
...
...
eth/downloader/peer.go
View file @
5c59d955
...
@@ -137,4 +137,5 @@ func (p *peer) demote() {
...
@@ -137,4 +137,5 @@ func (p *peer) demote() {
func
(
p
*
peer
)
reset
()
{
func
(
p
*
peer
)
reset
()
{
p
.
state
=
idleState
p
.
state
=
idleState
p
.
requested
.
Clear
()
}
}
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