mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
core: fix chain reorged if genesis parentHash not empty
If parentHash in genesis.json is set and not 0x0000... . When chain reorged , processSection will return error ""chain reorged during section processing"
This commit is contained in:
parent
1212c7b844
commit
c3e81107e5
1 changed files with 6 additions and 1 deletions
|
|
@ -325,8 +325,13 @@ func (c *ChainIndexer) updateLoop() {
|
|||
// Cache the current section count and head to allow unlocking the mutex
|
||||
section := c.storedSections
|
||||
var oldHead common.Hash
|
||||
var initParent common.Hash
|
||||
if section > 0 {
|
||||
oldHead = c.SectionHead(section - 1)
|
||||
} else if section == 0 {
|
||||
hash := rawdb.ReadCanonicalHash(c.chainDb, 0)
|
||||
initParent = rawdb.ReadHeader(c.chainDb, hash, 0).ParentHash
|
||||
oldHead = initParent
|
||||
}
|
||||
// Process the newly defined section in the background
|
||||
c.lock.Unlock()
|
||||
|
|
@ -343,7 +348,7 @@ func (c *ChainIndexer) updateLoop() {
|
|||
c.lock.Lock()
|
||||
|
||||
// If processing succeeded and no reorgs occcurred, mark the section completed
|
||||
if err == nil && oldHead == c.SectionHead(section-1) {
|
||||
if err == nil && (section > 0 && oldHead == c.SectionHead(section-1) || (section == 0 && oldHead == initParent)) {
|
||||
c.setSectionHead(section, newHead)
|
||||
c.setValidSections(section + 1)
|
||||
if c.storedSections == c.knownSections && updating {
|
||||
|
|
|
|||
Loading…
Reference in a new issue