core: fix deadlock in headers list init

This probably is a problem since adc880d323,
because AddHeaders() uses headersOp channel and its reader is only ran in
Run().
This commit is contained in:
Roman Khimov 2019-09-25 17:52:46 +03:00
parent 578ac414d4
commit 903173c991

View file

@ -148,8 +148,11 @@ func (bc *Blockchain) init() error {
}
headerSliceReverse(headers)
if err := bc.AddHeaders(headers...); err != nil {
return err
for _, h := range headers {
if !h.Verify() {
return fmt.Errorf("bad header %d/%s in the storage", h.Index, h.Hash())
}
bc.headerList.Add(h.Hash())
}
}