core: store current header reference on clean init
Missing it the following line could fail on subsequent restarts: currHeaderHeight, currHeaderHash, err := storage.CurrentHeaderHeight(bc.store) if the node was stopped before any headers had been received.
This commit is contained in:
parent
9f7625d699
commit
c16c2bf102
1 changed files with 4 additions and 0 deletions
|
@ -101,6 +101,10 @@ func (bc *Blockchain) init() error {
|
|||
return err
|
||||
}
|
||||
bc.headerList = NewHeaderHashList(genesisBlock.Hash())
|
||||
err = bc.store.Put(storage.SYSCurrentHeader.Bytes(), hashAndIndexToBytes(genesisBlock.Hash(), genesisBlock.Index))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return bc.storeBlock(genesisBlock)
|
||||
}
|
||||
if ver != version {
|
||||
|
|
Loading…
Reference in a new issue