mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-24 20:47:16 +00:00
Update instead of SaveStageProgress for stages.Header (#3456)
* Update instead of SaveStageProgress for stages.Header * Call WriteHeadHeaderHash/stage.Update after the loop
This commit is contained in:
parent
2e0602b8dd
commit
d6525b342d
@ -271,7 +271,7 @@ func handleForkChoice(
|
||||
return err
|
||||
}
|
||||
|
||||
return stages.SaveStageProgress(tx, stages.Headers, headerNumber)
|
||||
return s.Update(tx, headerNumber)
|
||||
}
|
||||
|
||||
func handleNewPayload(
|
||||
@ -386,7 +386,7 @@ func verifyAndSaveNewPoSHeader(
|
||||
return
|
||||
}
|
||||
|
||||
err = stages.SaveStageProgress(tx, stages.Headers, headerNumber)
|
||||
err = s.Update(tx, headerNumber)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -661,9 +661,18 @@ Loop:
|
||||
}
|
||||
if headerInserter.Unwind() {
|
||||
u.UnwindTo(headerInserter.UnwindPoint(), common.Hash{})
|
||||
} else if headerInserter.GetHighest() != 0 {
|
||||
if err := fixCanonicalChain(logPrefix, logEvery, headerInserter.GetHighest(), headerInserter.GetHighestHash(), tx, cfg.blockReader); err != nil {
|
||||
return fmt.Errorf("fix canonical chain: %w", err)
|
||||
}
|
||||
if headerInserter.GetHighest() != 0 {
|
||||
if !headerInserter.Unwind() {
|
||||
if err := fixCanonicalChain(logPrefix, logEvery, headerInserter.GetHighest(), headerInserter.GetHighestHash(), tx, cfg.blockReader); err != nil {
|
||||
return fmt.Errorf("fix canonical chain: %w", err)
|
||||
}
|
||||
}
|
||||
if err = rawdb.WriteHeadHeaderHash(tx, headerInserter.GetHighestHash()); err != nil {
|
||||
return fmt.Errorf("[%s] marking head header hash as %x: %w", logPrefix, headerInserter.GetHighestHash(), err)
|
||||
}
|
||||
if err = s.Update(tx, headerInserter.GetHighest()); err != nil {
|
||||
return fmt.Errorf("[%s] saving Headers progress: %w", logPrefix, err)
|
||||
}
|
||||
}
|
||||
if !useExternalTx {
|
||||
|
@ -902,12 +902,6 @@ func (hi *HeaderInserter) FeedHeaderPoW(db kv.StatelessRwTx, headerReader interf
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = rawdb.WriteHeadHeaderHash(db, hash); err != nil {
|
||||
return nil, fmt.Errorf("[%s] marking head header hash as %x: %w", hi.logPrefix, hash, err)
|
||||
}
|
||||
if err = stages.SaveStageProgress(db, stages.Headers, blockHeight); err != nil {
|
||||
return nil, fmt.Errorf("[%s] saving Headers progress: %w", hi.logPrefix, err)
|
||||
}
|
||||
hi.highest = blockHeight
|
||||
hi.highestHash = hash
|
||||
hi.highestTimestamp = header.Time
|
||||
|
Loading…
Reference in New Issue
Block a user