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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
1b5a867e
Unverified
Commit
1b5a867e
authored
Aug 22, 2020
by
Martin Holst Swende
Committed by
GitHub
Aug 22, 2020
Browse files
Options
Downloads
Patches
Plain Diff
core: do less lookups when writing fast-sync block bodies (#21468)
parent
87c0ba92
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/blockchain.go
+12
-3
12 additions, 3 deletions
core/blockchain.go
with
12 additions
and
3 deletions
core/blockchain.go
+
12
−
3
View file @
1b5a867e
...
@@ -1277,6 +1277,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
...
@@ -1277,6 +1277,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
}
}
// writeLive writes blockchain and corresponding receipt chain into active store.
// writeLive writes blockchain and corresponding receipt chain into active store.
writeLive
:=
func
(
blockChain
types
.
Blocks
,
receiptChain
[]
types
.
Receipts
)
(
int
,
error
)
{
writeLive
:=
func
(
blockChain
types
.
Blocks
,
receiptChain
[]
types
.
Receipts
)
(
int
,
error
)
{
skipPresenceCheck
:=
false
batch
:=
bc
.
db
.
NewBatch
()
batch
:=
bc
.
db
.
NewBatch
()
for
i
,
block
:=
range
blockChain
{
for
i
,
block
:=
range
blockChain
{
// Short circuit insertion if shutting down or processing failed
// Short circuit insertion if shutting down or processing failed
...
@@ -1287,9 +1288,17 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
...
@@ -1287,9 +1288,17 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
if
!
bc
.
HasHeader
(
block
.
Hash
(),
block
.
NumberU64
())
{
if
!
bc
.
HasHeader
(
block
.
Hash
(),
block
.
NumberU64
())
{
return
i
,
fmt
.
Errorf
(
"containing header #%d [%x…] unknown"
,
block
.
Number
(),
block
.
Hash
()
.
Bytes
()[
:
4
])
return
i
,
fmt
.
Errorf
(
"containing header #%d [%x…] unknown"
,
block
.
Number
(),
block
.
Hash
()
.
Bytes
()[
:
4
])
}
}
if
!
skipPresenceCheck
{
// Ignore if the entire data is already known
if
bc
.
HasBlock
(
block
.
Hash
(),
block
.
NumberU64
())
{
if
bc
.
HasBlock
(
block
.
Hash
(),
block
.
NumberU64
())
{
stats
.
ignored
++
stats
.
ignored
++
continue
continue
}
else
{
// If block N is not present, neither are the later blocks.
// This should be true, but if we are mistaken, the shortcut
// here will only cause overwriting of some existing data
skipPresenceCheck
=
true
}
}
}
// Write all the data out into the database
// Write all the data out into the database
rawdb
.
WriteBody
(
batch
,
block
.
Hash
(),
block
.
NumberU64
(),
block
.
Body
())
rawdb
.
WriteBody
(
batch
,
block
.
Hash
(),
block
.
NumberU64
(),
block
.
Body
())
...
...
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