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
1b5a867e
Unverified
Commit
1b5a867e
authored
Aug 22, 2020
by
Martin Holst Swende
Committed by
GitHub
Aug 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: do less lookups when writing fast-sync block bodies (#21468)
parent
87c0ba92
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
blockchain.go
core/blockchain.go
+12
-3
No files found.
core/blockchain.go
View file @
1b5a867e
...
...
@@ -1277,6 +1277,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
}
// writeLive writes blockchain and corresponding receipt chain into active store.
writeLive
:=
func
(
blockChain
types
.
Blocks
,
receiptChain
[]
types
.
Receipts
)
(
int
,
error
)
{
skipPresenceCheck
:=
false
batch
:=
bc
.
db
.
NewBatch
()
for
i
,
block
:=
range
blockChain
{
// Short circuit insertion if shutting down or processing failed
...
...
@@ -1287,9 +1288,17 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
if
!
bc
.
HasHeader
(
block
.
Hash
(),
block
.
NumberU64
())
{
return
i
,
fmt
.
Errorf
(
"containing header #%d [%x…] unknown"
,
block
.
Number
(),
block
.
Hash
()
.
Bytes
()[
:
4
])
}
if
bc
.
HasBlock
(
block
.
Hash
(),
block
.
NumberU64
())
{
stats
.
ignored
++
continue
if
!
skipPresenceCheck
{
// Ignore if the entire data is already known
if
bc
.
HasBlock
(
block
.
Hash
(),
block
.
NumberU64
())
{
stats
.
ignored
++
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
rawdb
.
WriteBody
(
batch
,
block
.
Hash
(),
block
.
NumberU64
(),
block
.
Body
())
...
...
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