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
8f873b76
Commit
8f873b76
authored
Apr 18, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
downloader: all handlers check for isBusy
parent
a6c0a75f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
downloader.go
eth/downloader/downloader.go
+7
-7
No files found.
eth/downloader/downloader.go
View file @
8f873b76
...
@@ -116,7 +116,7 @@ func (d *Downloader) UnregisterPeer(id string) {
...
@@ -116,7 +116,7 @@ func (d *Downloader) UnregisterPeer(id string) {
// checks fail an error will be returned. This method is synchronous
// checks fail an error will be returned. This method is synchronous
func
(
d
*
Downloader
)
SynchroniseWithPeer
(
id
string
)
(
types
.
Blocks
,
error
)
{
func
(
d
*
Downloader
)
SynchroniseWithPeer
(
id
string
)
(
types
.
Blocks
,
error
)
{
// Check if we're busy
// Check if we're busy
if
d
.
is
FetchingHashes
()
||
d
.
isDownloadingBlocks
()
||
d
.
isProcessing
()
{
if
d
.
is
Busy
()
{
return
nil
,
errBusy
return
nil
,
errBusy
}
}
...
@@ -213,7 +213,7 @@ func (d *Downloader) selectPeer(p *peer) {
...
@@ -213,7 +213,7 @@ func (d *Downloader) selectPeer(p *peer) {
// Make sure it's doing neither. Once done we can restart the
// Make sure it's doing neither. Once done we can restart the
// downloading process if the TD is higher. For now just get on
// downloading process if the TD is higher. For now just get on
// with whatever is going on. This prevents unecessary switching.
// with whatever is going on. This prevents unecessary switching.
if
!
(
d
.
isFetchingHashes
()
||
d
.
isDownloadingBlocks
()
||
d
.
isProcessing
()
)
{
if
!
d
.
isBusy
(
)
{
// selected peer must be better than our own
// selected peer must be better than our own
// XXX we also check the peer's recent hash to make sure we
// XXX we also check the peer's recent hash to make sure we
// don't have it. Some peers report (i think) incorrect TD.
// don't have it. Some peers report (i think) incorrect TD.
...
@@ -340,10 +340,6 @@ out:
...
@@ -340,10 +340,6 @@ out:
// from the available peers.
// from the available peers.
if
d
.
queue
.
hashPool
.
Size
()
>
0
{
if
d
.
queue
.
hashPool
.
Size
()
>
0
{
availablePeers
:=
d
.
peers
.
get
(
idleState
)
availablePeers
:=
d
.
peers
.
get
(
idleState
)
if
len
(
availablePeers
)
==
0
{
glog
.
V
(
logger
.
Detail
)
.
Infoln
(
"No peers available out of"
,
len
(
d
.
peers
))
}
for
_
,
peer
:=
range
availablePeers
{
for
_
,
peer
:=
range
availablePeers
{
// Get a possible chunk. If nil is returned no chunk
// Get a possible chunk. If nil is returned no chunk
// could be returned due to no hashes available.
// could be returned due to no hashes available.
...
@@ -440,7 +436,7 @@ func (d *Downloader) AddBlock(id string, block *types.Block, td *big.Int) {
...
@@ -440,7 +436,7 @@ func (d *Downloader) AddBlock(id string, block *types.Block, td *big.Int) {
d
.
queue
.
addBlock
(
id
,
block
,
td
)
d
.
queue
.
addBlock
(
id
,
block
,
td
)
// if neither go ahead to process
// if neither go ahead to process
if
!
(
d
.
isFetchingHashes
()
||
d
.
isDownloadingBlocks
()
)
{
if
!
d
.
isBusy
(
)
{
// Check if the parent of the received block is known.
// Check if the parent of the received block is known.
// If the block is not know, request it otherwise, request.
// If the block is not know, request it otherwise, request.
phash
:=
block
.
ParentHash
()
phash
:=
block
.
ParentHash
()
...
@@ -519,3 +515,7 @@ func (d *Downloader) isDownloadingBlocks() bool {
...
@@ -519,3 +515,7 @@ func (d *Downloader) isDownloadingBlocks() bool {
func
(
d
*
Downloader
)
isProcessing
()
bool
{
func
(
d
*
Downloader
)
isProcessing
()
bool
{
return
atomic
.
LoadInt32
(
&
d
.
processingBlocks
)
==
1
return
atomic
.
LoadInt32
(
&
d
.
processingBlocks
)
==
1
}
}
func
(
d
*
Downloader
)
isBusy
()
bool
{
return
d
.
isFetchingHashes
()
||
d
.
isDownloadingBlocks
()
||
d
.
isProcessing
()
}
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