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
f0515800
Commit
f0515800
authored
Nov 26, 2018
by
Felföldi Zsolt
Committed by
Péter Szilágyi
Nov 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
les: fix fetcher syncing logic (#18072)
parent
bb29d208
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
27 deletions
+29
-27
fetcher.go
les/fetcher.go
+29
-27
No files found.
les/fetcher.go
View file @
f0515800
...
...
@@ -141,36 +141,39 @@ func (f *lightFetcher) syncLoop() {
s
:=
requesting
requesting
=
false
var
(
rq
*
distReq
reqID
uint64
rq
*
distReq
reqID
uint64
syncing
bool
)
if
!
f
.
syncing
&&
!
(
newAnnounce
&&
s
)
{
rq
,
reqID
=
f
.
nextRequest
()
rq
,
reqID
,
syncing
=
f
.
nextRequest
()
}
syncing
:=
f
.
syncing
f
.
lock
.
Unlock
()
if
rq
!=
nil
{
requesting
=
true
_
,
ok
:=
<-
f
.
pm
.
reqDist
.
queue
(
rq
)
if
!
ok
{
if
_
,
ok
:=
<-
f
.
pm
.
reqDist
.
queue
(
rq
);
ok
{
if
syncing
{
f
.
lock
.
Lock
()
f
.
syncing
=
true
f
.
lock
.
Unlock
()
}
else
{
go
func
()
{
time
.
Sleep
(
softRequestTimeout
)
f
.
reqMu
.
Lock
()
req
,
ok
:=
f
.
requested
[
reqID
]
if
ok
{
req
.
timeout
=
true
f
.
requested
[
reqID
]
=
req
}
f
.
reqMu
.
Unlock
()
// keep starting new requests while possible
f
.
requestChn
<-
false
}()
}
}
else
{
f
.
requestChn
<-
false
}
if
!
syncing
{
go
func
()
{
time
.
Sleep
(
softRequestTimeout
)
f
.
reqMu
.
Lock
()
req
,
ok
:=
f
.
requested
[
reqID
]
if
ok
{
req
.
timeout
=
true
f
.
requested
[
reqID
]
=
req
}
f
.
reqMu
.
Unlock
()
// keep starting new requests while possible
f
.
requestChn
<-
false
}()
}
}
case
reqID
:=
<-
f
.
timeoutChn
:
f
.
reqMu
.
Lock
()
...
...
@@ -209,6 +212,7 @@ func (f *lightFetcher) syncLoop() {
f
.
checkSyncedHeaders
(
p
)
f
.
syncing
=
false
f
.
lock
.
Unlock
()
f
.
requestChn
<-
false
}
}
}
...
...
@@ -405,7 +409,7 @@ func (f *lightFetcher) requestedID(reqID uint64) bool {
// nextRequest selects the peer and announced head to be requested next, amount
// to be downloaded starting from the head backwards is also returned
func
(
f
*
lightFetcher
)
nextRequest
()
(
*
distReq
,
uint64
)
{
func
(
f
*
lightFetcher
)
nextRequest
()
(
*
distReq
,
uint64
,
bool
)
{
var
(
bestHash
common
.
Hash
bestAmount
uint64
...
...
@@ -427,14 +431,12 @@ func (f *lightFetcher) nextRequest() (*distReq, uint64) {
}
}
if
bestTd
==
f
.
maxConfirmedTd
{
return
nil
,
0
return
nil
,
0
,
false
}
f
.
syncing
=
bestSyncing
var
rq
*
distReq
reqID
:=
genReqID
()
if
f
.
s
yncing
{
if
bestS
yncing
{
rq
=
&
distReq
{
getCost
:
func
(
dp
distPeer
)
uint64
{
return
0
...
...
@@ -500,7 +502,7 @@ func (f *lightFetcher) nextRequest() (*distReq, uint64) {
},
}
}
return
rq
,
reqID
return
rq
,
reqID
,
bestSyncing
}
// deliverHeaders delivers header download request responses for processing
...
...
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