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:
Roman Khimov 2019-11-06 17:56:06 +03:00
parent 9f7625d699
commit c16c2bf102

View file

@ -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 {