aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-11-28 17:21:26 +0800
committerWei-Ning Huang <w@dexon.org>2019-03-12 12:19:09 +0800
commit214986305ecdc0439cff8771f3235e0ecdb54c8e (patch)
tree7efa1894e3400181e54c24af0d9dcb493b2882bf
parent3ca44e556bd9561b0c6c64c7d3a4f95726c78be8 (diff)
downloaddexon-214986305ecdc0439cff8771f3235e0ecdb54c8e.tar.gz
dexon-214986305ecdc0439cff8771f3235e0ecdb54c8e.tar.zst
dexon-214986305ecdc0439cff8771f3235e0ecdb54c8e.zip
core: panic if fork found when inserting header chain (#61)
-rw-r--r--core/blockchain.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 711457ac1..30552471a 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -2216,7 +2216,12 @@ func (bc *BlockChain) InsertDexonHeaderChain(chain []*types.HeaderWithGovState,
whFunc := func(header *types.HeaderWithGovState) error {
bc.mu.Lock()
defer bc.mu.Unlock()
- _, err := bc.hc.WriteDexonHeader(header)
+ status, err := bc.hc.WriteDexonHeader(header)
+ if status == SideStatTy {
+ log.Debug("Inserted forked block header", "number", header.Number, "hash", header.Hash, "diff", header.Difficulty,
+ "gas", header.GasUsed)
+ panic("fork found")
+ }
return err
}