Merge pull request #417 from dinhln89/rollback

Fixed reset head chain to block number for rollback block hash feature.
This commit is contained in:
Tuna 2019-01-23 16:10:48 +07:00 committed by GitHub
commit d90ecdf03c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -179,6 +179,14 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
eth.blockchain.Rollback([]common.Hash{curBlock.Hash()}) eth.blockchain.Rollback([]common.Hash{curBlock.Hash()})
} }
} }
if prevBlock != nil {
err := eth.blockchain.SetHead(prevBlock.NumberU64())
if err != nil {
log.Crit("Err Rollback", "err", err)
return nil, err
}
}
} }
if eth.protocolManager, err = NewProtocolManager(eth.chainConfig, config.SyncMode, config.NetworkId, eth.eventMux, eth.txPool, eth.engine, eth.blockchain, chainDb); err != nil { if eth.protocolManager, err = NewProtocolManager(eth.chainConfig, config.SyncMode, config.NetworkId, eth.eventMux, eth.txPool, eth.engine, eth.blockchain, chainDb); err != nil {