core: fix snapshot missing when recovery from crash (#23496)

It is because write known block only checks block and state without snapshot, which could lead to gap between newest snapshot and newest block state. However, new blocks which would cause snapshot to become fixed were ignored, since state was already known. 


Co-authored-by: Gary Rong <garyrong0905@gmail.com>
Co-authored-by: Martin Holst Swende <martin@swende.se>
This commit is contained in:
Ziyuan Zhong(仲梓源)
2021-11-01 21:09:36 +08:00
committed by GitHub
parent c2e64db3b1
commit c576fa153a
3 changed files with 182 additions and 10 deletions

View File

@ -150,6 +150,14 @@ func (it *insertIterator) previous() *types.Header {
return it.chain[it.index-1].Header()
}
// current returns the current header that is being processed, or nil.
func (it *insertIterator) current() *types.Header {
if it.index == -1 || it.index >= len(it.chain) {
return nil
}
return it.chain[it.index].Header()
}
// first returns the first block in the it.
func (it *insertIterator) first() *types.Block {
return it.chain[0]