parlia: the newChainHead mights not be imported to Pralia.Snapshot ASAP

This commit is contained in:
Jolly Zhao 2022-10-20 01:45:32 +08:00 committed by Larry
parent cb131fabe5
commit c46671df97
2 changed files with 4 additions and 4 deletions

@ -929,8 +929,8 @@ func (p *Parlia) IsLocalBlock(header *types.Header) bool {
return p.val == header.Coinbase
}
func (p *Parlia) SignRecently(chain consensus.ChainReader, parent *types.Header) (bool, error) {
snap, err := p.snapshot(chain, parent.Number.Uint64(), parent.ParentHash, nil)
func (p *Parlia) SignRecently(chain consensus.ChainReader, parent *types.Block) (bool, error) {
snap, err := p.snapshot(chain, parent.NumberU64(), parent.Hash(), nil)
if err != nil {
return true, err
}
@ -941,7 +941,7 @@ func (p *Parlia) SignRecently(chain consensus.ChainReader, parent *types.Header)
}
// If we're amongst the recent signers, wait for the next block
number := parent.Number.Uint64() + 1
number := parent.NumberU64() + 1
for seen, recent := range snap.Recents {
if recent == p.val {
// Signer is among recents, only wait if the current block doesn't shift it out

@ -470,7 +470,7 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
clearPending(head.Block.NumberU64())
timestamp = time.Now().Unix()
if p, ok := w.engine.(*parlia.Parlia); ok {
signedRecent, err := p.SignRecently(w.chain, head.Block.Header())
signedRecent, err := p.SignRecently(w.chain, head.Block)
if err != nil {
log.Info("Not allowed to propose block", "err", err)
continue