From 253d98ca0bdcbbbc9ac3b42b74f25041ddb43f9f Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Wed, 3 Jul 2019 15:29:34 +0800 Subject: [PATCH] core: fix chain indexer This PR fixes an issue in chain indexer. Currently chain indexer will validate whether the stored data is canonical by comparing section head and canonical hash. But the header of the checkpoint may not exist in the database. We should skip validation for sections below the checkpoint. --- core/chain_indexer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/chain_indexer.go b/core/chain_indexer.go index c82febb545..c0c2c4f7f9 100644 --- a/core/chain_indexer.go +++ b/core/chain_indexer.go @@ -418,7 +418,7 @@ func (c *ChainIndexer) processSection(section uint64, lastHead common.Hash) (com // actual canonical chain and rolls back reorged sections if necessary to ensure that stored // sections are all valid func (c *ChainIndexer) verifyLastHead() { - for c.storedSections > 0 { + for c.storedSections > 0 && c.storedSections > c.checkpointSections { if c.SectionHead(c.storedSections-1) == rawdb.ReadCanonicalHash(c.chainDb, c.storedSections*c.sectionSize-1) { return }