aboutsummaryrefslogtreecommitdiffstats
path: root/core/chain_indexer.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-10-03 18:42:19 +0800
committerGitHub <noreply@github.com>2018-10-03 18:42:19 +0800
commit14bef9a2dba1f6370c694779962e742e9853fdc6 (patch)
treedc38694ed218338785811b51a6f43b4622e5c74d /core/chain_indexer.go
parentd3a773c284103401090c4c806d6641d6f6fddcf5 (diff)
downloaddexon-14bef9a2dba1f6370c694779962e742e9853fdc6.tar
dexon-14bef9a2dba1f6370c694779962e742e9853fdc6.tar.gz
dexon-14bef9a2dba1f6370c694779962e742e9853fdc6.tar.bz2
dexon-14bef9a2dba1f6370c694779962e742e9853fdc6.tar.lz
dexon-14bef9a2dba1f6370c694779962e742e9853fdc6.tar.xz
dexon-14bef9a2dba1f6370c694779962e742e9853fdc6.tar.zst
dexon-14bef9a2dba1f6370c694779962e742e9853fdc6.zip
core: fix unnecessary ancestor lookup after a fast sync (#17825)
Diffstat (limited to 'core/chain_indexer.go')
-rw-r--r--core/chain_indexer.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/chain_indexer.go b/core/chain_indexer.go
index 4bdd4ba1c..28dc47668 100644
--- a/core/chain_indexer.go
+++ b/core/chain_indexer.go
@@ -219,13 +219,13 @@ func (c *ChainIndexer) eventLoop(currentHeader *types.Header, events chan ChainE
}
header := ev.Block.Header()
if header.ParentHash != prevHash {
- // Reorg to the common ancestor (might not exist in light sync mode, skip reorg then)
+ // Reorg to the common ancestor if needed (might not exist in light sync mode, skip reorg then)
// TODO(karalabe, zsfelfoldi): This seems a bit brittle, can we detect this case explicitly?
- // TODO(karalabe): This operation is expensive and might block, causing the event system to
- // potentially also lock up. We need to do with on a different thread somehow.
- if h := rawdb.FindCommonAncestor(c.chainDb, prevHeader, header); h != nil {
- c.newHead(h.Number.Uint64(), true)
+ if rawdb.ReadCanonicalHash(c.chainDb, prevHeader.Number.Uint64()) != prevHash {
+ if h := rawdb.FindCommonAncestor(c.chainDb, prevHeader, header); h != nil {
+ c.newHead(h.Number.Uint64(), true)
+ }
}
}
c.newHead(header.Number.Uint64(), false)