mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-10 15:04:27 +00:00
add initial function during load latest block from db (#96)
This commit is contained in:
parent
7effc71547
commit
0317e871d4
2 changed files with 16 additions and 0 deletions
|
|
@ -130,6 +130,15 @@ func NewFaker(db ethdb.Database, chainConfig *params.ChainConfig) *XDPoS {
|
||||||
return fakeEngine
|
return fakeEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *XDPoS) Initial(chain consensus.ChainReader, header *types.Header) error {
|
||||||
|
switch x.config.BlockConsensusVersion(header.Number) {
|
||||||
|
case params.ConsensusEngineVersion2:
|
||||||
|
return x.EngineV2.Initial(chain, header)
|
||||||
|
default: // Default "v1"
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Eth Consensus engine interface implementation
|
Eth Consensus engine interface implementation
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -352,6 +352,13 @@ func (bc *BlockChain) loadLastState() error {
|
||||||
}
|
}
|
||||||
bc.hc.SetCurrentHeader(currentHeader)
|
bc.hc.SetCurrentHeader(currentHeader)
|
||||||
|
|
||||||
|
if engine, ok := bc.Engine().(*XDPoS.XDPoS); ok {
|
||||||
|
err := engine.Initial(bc, currentHeader)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Restore the last known head fast block
|
// Restore the last known head fast block
|
||||||
bc.currentFastBlock.Store(currentBlock)
|
bc.currentFastBlock.Store(currentBlock)
|
||||||
if head := GetHeadFastBlockHash(bc.db); head != (common.Hash{}) {
|
if head := GetHeadFastBlockHash(bc.db); head != (common.Hash{}) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue