|
|
@ -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,
|
|
|
|
// GetHeader retrieves a block header from the database by hash and number,
|
|
|
|
// caching it if found.
|
|
|
|
// caching it if found.
|
|
|
|
func (bc *BlockChain) GetHeader(hash common.Hash, number uint64) *types.Header { |
|
|
|
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) |
|
|
|
return bc.hc.GetHeader(hash, number) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// GetHeaderByHash retrieves a block header from the database by hash, caching it if
|
|
|
|
// GetHeaderByHash retrieves a block header from the database by hash, caching it if
|
|
|
|
// found.
|
|
|
|
// found.
|
|
|
|
func (bc *BlockChain) GetHeaderByHash(hash common.Hash) *types.Header { |
|
|
|
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) |
|
|
|
return bc.hc.GetHeaderByHash(hash) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|