core: init genesis block header if there are no other headers in DB

Fixes crash when restarted after the DB initialization and no blocks written
into the DB.
This commit is contained in:
Roman Khimov 2019-11-06 17:58:19 +03:00
parent c16c2bf102
commit b5199625cd

View file

@ -135,6 +135,9 @@ func (bc *Blockchain) init() error {
if err != nil { if err != nil {
return err return err
} }
if bc.storedHeaderCount == 0 && currHeaderHeight == 0 {
bc.headerList.Add(currHeaderHash)
}
// There is a high chance that the Node is stopped before the next // There is a high chance that the Node is stopped before the next
// batch of 2000 headers was stored. Via the currentHeaders stored we can sync // batch of 2000 headers was stored. Via the currentHeaders stored we can sync