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
c38fab91
Unverified
Commit
c38fab91
authored
Aug 03, 2021
by
Sina Mahmoodi
Committed by
GitHub
Aug 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: get header from block cache (#23299)
parent
4cd6a145
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
blockchain.go
core/blockchain.go
+10
-0
No files found.
core/blockchain.go
View file @
c38fab91
...
...
@@ -2417,12 +2417,22 @@ func (bc *BlockChain) GetTdByHash(hash common.Hash) *big.Int {
// GetHeader retrieves a block header from the database by hash and number,
// caching it if found.
func
(
bc
*
BlockChain
)
GetHeader
(
hash
common
.
Hash
,
number
uint64
)
*
types
.
Header
{
// Blockchain might have cached the whole block, only if not go to headerchain
if
block
,
ok
:=
bc
.
blockCache
.
Get
(
hash
);
ok
{
return
block
.
(
*
types
.
Block
)
.
Header
()
}
return
bc
.
hc
.
GetHeader
(
hash
,
number
)
}
// GetHeaderByHash retrieves a block header from the database by hash, caching it if
// found.
func
(
bc
*
BlockChain
)
GetHeaderByHash
(
hash
common
.
Hash
)
*
types
.
Header
{
// Blockchain might have cached the whole block, only if not go to headerchain
if
block
,
ok
:=
bc
.
blockCache
.
Get
(
hash
);
ok
{
return
block
.
(
*
types
.
Block
)
.
Header
()
}
return
bc
.
hc
.
GetHeaderByHash
(
hash
)
}
...
...
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