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
github
maticnetwork
bor
Commits
1bdde620
Commit
1bdde620
authored
7 years ago
by
Zsolt Felföldi
Committed by
Péter Szilágyi
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
les: fix light fetcher database race (#16103)
* les: fix light fetcher database race * les: lightFetcher comments
parent
06c5cae3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
les/fetcher.go
+21
-9
21 additions, 9 deletions
les/fetcher.go
with
21 additions
and
9 deletions
les/fetcher.go
+
21
−
9
View file @
1bdde620
...
...
@@ -36,24 +36,26 @@ const (
maxNodeCount
=
20
// maximum number of fetcherTreeNode entries remembered for each peer
)
// lightFetcher
// lightFetcher implements retrieval of newly announced headers. It also provides a peerHasBlock function for the
// ODR system to ensure that we only request data related to a certain block from peers who have already processed
// and announced that block.
type
lightFetcher
struct
{
pm
*
ProtocolManager
odr
*
LesOdr
chain
*
light
.
LightChain
lock
sync
.
Mutex
// lock protects access to the fetcher's internal state variables except sent requests
maxConfirmedTd
*
big
.
Int
peers
map
[
*
peer
]
*
fetcherPeerInfo
lastUpdateStats
*
updateStatsEntry
syncing
bool
syncDone
chan
*
peer
lock
sync
.
Mutex
// qwerqwerqwe
deliverChn
chan
fetchResponse
reqMu
sync
.
RWMutex
reqMu
sync
.
RWMutex
// reqMu protects access to sent header fetch requests
requested
map
[
uint64
]
fetchRequest
deliverChn
chan
fetchResponse
timeoutChn
chan
uint64
requestChn
chan
bool
// true if initiated from outside
syncing
bool
syncDone
chan
*
peer
}
// fetcherPeerInfo holds fetcher-specific information about each active peer
...
...
@@ -560,8 +562,13 @@ func (f *lightFetcher) checkAnnouncedHeaders(fp *fetcherPeerInfo, headers []*typ
return
true
}
// we ran out of recently delivered headers but have not reached a node known by this peer yet, continue matching
td
=
f
.
chain
.
GetTd
(
header
.
ParentHash
,
header
.
Number
.
Uint64
()
-
1
)
header
=
f
.
chain
.
GetHeader
(
header
.
ParentHash
,
header
.
Number
.
Uint64
()
-
1
)
hash
,
number
:=
header
.
ParentHash
,
header
.
Number
.
Uint64
()
-
1
td
=
f
.
chain
.
GetTd
(
hash
,
number
)
header
=
f
.
chain
.
GetHeader
(
hash
,
number
)
if
header
==
nil
||
td
==
nil
{
log
.
Error
(
"Missing parent of validated header"
,
"hash"
,
hash
,
"number"
,
number
)
return
false
}
}
else
{
header
=
headers
[
i
]
td
=
tds
[
i
]
...
...
@@ -645,13 +652,18 @@ func (f *lightFetcher) checkKnownNode(p *peer, n *fetcherTreeNode) bool {
if
td
==
nil
{
return
false
}
header
:=
f
.
chain
.
GetHeader
(
n
.
hash
,
n
.
number
)
// check the availability of both header and td because reads are not protected by chain db mutex
// Note: returning false is always safe here
if
header
==
nil
{
return
false
}
fp
:=
f
.
peers
[
p
]
if
fp
==
nil
{
p
.
Log
()
.
Debug
(
"Unknown peer to check known nodes"
)
return
false
}
header
:=
f
.
chain
.
GetHeader
(
n
.
hash
,
n
.
number
)
if
!
f
.
checkAnnouncedHeaders
(
fp
,
[]
*
types
.
Header
{
header
},
[]
*
big
.
Int
{
td
})
{
p
.
Log
()
.
Debug
(
"Inconsistent announcement"
)
go
f
.
pm
.
removePeer
(
p
.
id
)
...
...
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