aboutsummaryrefslogtreecommitdiffstats
path: root/core/blockchain.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-03-11 02:19:09 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-03-11 03:40:34 +0800
commitdaad2b25596a1cd25a570d9cb2a747a702e17901 (patch)
treed5ad685b3f2d2d62f5c3f951725b86d103cccfba /core/blockchain.go
parent8b58cd01907ff4dffdca4e7fe250b7371a574b61 (diff)
downloaddexon-daad2b25596a1cd25a570d9cb2a747a702e17901.tar
dexon-daad2b25596a1cd25a570d9cb2a747a702e17901.tar.gz
dexon-daad2b25596a1cd25a570d9cb2a747a702e17901.tar.bz2
dexon-daad2b25596a1cd25a570d9cb2a747a702e17901.tar.lz
dexon-daad2b25596a1cd25a570d9cb2a747a702e17901.tar.xz
dexon-daad2b25596a1cd25a570d9cb2a747a702e17901.tar.zst
dexon-daad2b25596a1cd25a570d9cb2a747a702e17901.zip
core: cache fresh headers and tds to avoid db trashing
Diffstat (limited to 'core/blockchain.go')
-rw-r--r--core/blockchain.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 83299ceec..4940899a5 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -368,7 +368,7 @@ func (bc *BlockChain) ResetWithGenesisBlock(genesis *types.Block) {
defer bc.mu.Unlock()
// Prepare the genesis block and reinitialise the chain
- if err := WriteTd(bc.chainDb, genesis.Hash(), genesis.Difficulty()); err != nil {
+ if err := bc.hc.WriteTd(genesis.Hash(), genesis.Difficulty()); err != nil {
glog.Fatalf("failed to write genesis block TD: %v", err)
}
if err := WriteBlock(bc.chainDb, genesis); err != nil {
@@ -788,7 +788,7 @@ func (self *BlockChain) WriteBlock(block *types.Block) (status WriteStatus, err
status = SideStatTy
}
// Irrelevant of the canonical status, write the block itself to the database
- if err := WriteTd(self.chainDb, block.Hash(), externTd); err != nil {
+ if err := self.hc.WriteTd(block.Hash(), externTd); err != nil {
glog.Fatalf("failed to write block total difficulty: %v", err)
}
if err := WriteBlock(self.chainDb, block); err != nil {