core: add a workaround for light sync

This commit is contained in:
Péter Szilágyi 2017-10-25 11:59:07 +03:00
parent 192d23327c
commit af93ad5e30
No known key found for this signature in database
GPG key ID: E9AE538CEDF8293D

View file

@ -201,7 +201,11 @@ func (c *ChainIndexer) eventLoop(currentHeader *types.Header, events chan ChainE
} }
header := ev.Block.Header() header := ev.Block.Header()
if header.ParentHash != prevHash { if header.ParentHash != prevHash {
c.newHead(FindCommonAncestor(c.chainDb, prevHeader, header).Number.Uint64(), true) // Reorg to the common ancestor (might not exist in light sync mode, skip reorg then)
// TODO(karalabe, zsfelfoldi): This seems a bit brittle, can we detect this case explicitly?
if h := FindCommonAncestor(c.chainDb, prevHeader, header); h != nil {
c.newHead(h.Number.Uint64(), true)
}
} }
c.newHead(header.Number.Uint64(), false) c.newHead(header.Number.Uint64(), false)