mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-31 16:21:21 +00:00
Fix snapshot merge and anchor removal (#4228)
* Print retire * Print * Print * Print * Print * Not fail when block is not found * Remove prints Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This commit is contained in:
parent
2ec9733cee
commit
9dc7067e9c
@ -1126,17 +1126,18 @@ func DeleteAncientBlocks(db kv.RwTx, blockTo uint64, blocksDeleteLimit int) erro
|
||||
return err
|
||||
}
|
||||
if b == nil {
|
||||
return fmt.Errorf("DeleteAncientBlocks: block body not found for block %d", n)
|
||||
}
|
||||
txIDBytes := make([]byte, 8)
|
||||
for txID := b.BaseTxId; txID < b.BaseTxId+uint64(b.TxAmount); txID++ {
|
||||
binary.BigEndian.PutUint64(txIDBytes, txID)
|
||||
bucket := kv.EthTx
|
||||
if !isCanonical {
|
||||
bucket = kv.NonCanonicalTxs
|
||||
}
|
||||
if err := db.Delete(bucket, txIDBytes, nil); err != nil {
|
||||
return err
|
||||
log.Warn("DeleteAncientBlocks: block body not found", "height", n)
|
||||
} else {
|
||||
txIDBytes := make([]byte, 8)
|
||||
for txID := b.BaseTxId; txID < b.BaseTxId+uint64(b.TxAmount); txID++ {
|
||||
binary.BigEndian.PutUint64(txIDBytes, txID)
|
||||
bucket := kv.EthTx
|
||||
if !isCanonical {
|
||||
bucket = kv.NonCanonicalTxs
|
||||
}
|
||||
if err := db.Delete(bucket, txIDBytes, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := db.Delete(kv.Headers, k, nil); err != nil {
|
||||
|
@ -195,8 +195,6 @@ func (hd *HeaderDownload) removeAnchor(anchor *Anchor) {
|
||||
// Anchor is removed from the map, and from the priority queue
|
||||
delete(hd.anchors, anchor.parentHash)
|
||||
heap.Remove(hd.anchorQueue, anchor.idx)
|
||||
for child := anchor.fLink; child != nil; child, child.next = child.next, nil {
|
||||
}
|
||||
anchor.idx = -1
|
||||
}
|
||||
|
||||
@ -375,6 +373,8 @@ func (hd *HeaderDownload) ReadProgressFromDb(tx kv.RwTx) (err error) {
|
||||
func (hd *HeaderDownload) invalidateAnchor(anchor *Anchor, reason string) {
|
||||
log.Debug("Invalidating anchor", "height", anchor.blockHeight, "hash", anchor.parentHash, "reason", reason)
|
||||
hd.removeAnchor(anchor)
|
||||
for child := anchor.fLink; child != nil; child, child.next = child.next, nil {
|
||||
}
|
||||
hd.removeUpwards(anchor.fLink)
|
||||
}
|
||||
|
||||
@ -937,7 +937,6 @@ func (hd *HeaderDownload) ProcessHeader(sh ChainSegmentHeader, newBlock bool, pe
|
||||
peerID: peerID,
|
||||
blockHeight: sh.Number,
|
||||
}
|
||||
link.next = anchor.fLink
|
||||
anchor.fLink = link
|
||||
hd.anchors[anchor.parentHash] = anchor
|
||||
heap.Push(hd.anchorQueue, anchor)
|
||||
|
Loading…
Reference in New Issue
Block a user