mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-18 16:44:12 +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
|
return err
|
||||||
}
|
}
|
||||||
if b == nil {
|
if b == nil {
|
||||||
return fmt.Errorf("DeleteAncientBlocks: block body not found for block %d", n)
|
log.Warn("DeleteAncientBlocks: block body not found", "height", n)
|
||||||
}
|
} else {
|
||||||
txIDBytes := make([]byte, 8)
|
txIDBytes := make([]byte, 8)
|
||||||
for txID := b.BaseTxId; txID < b.BaseTxId+uint64(b.TxAmount); txID++ {
|
for txID := b.BaseTxId; txID < b.BaseTxId+uint64(b.TxAmount); txID++ {
|
||||||
binary.BigEndian.PutUint64(txIDBytes, txID)
|
binary.BigEndian.PutUint64(txIDBytes, txID)
|
||||||
bucket := kv.EthTx
|
bucket := kv.EthTx
|
||||||
if !isCanonical {
|
if !isCanonical {
|
||||||
bucket = kv.NonCanonicalTxs
|
bucket = kv.NonCanonicalTxs
|
||||||
}
|
}
|
||||||
if err := db.Delete(bucket, txIDBytes, nil); err != nil {
|
if err := db.Delete(bucket, txIDBytes, nil); err != nil {
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := db.Delete(kv.Headers, k, nil); err != nil {
|
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
|
// Anchor is removed from the map, and from the priority queue
|
||||||
delete(hd.anchors, anchor.parentHash)
|
delete(hd.anchors, anchor.parentHash)
|
||||||
heap.Remove(hd.anchorQueue, anchor.idx)
|
heap.Remove(hd.anchorQueue, anchor.idx)
|
||||||
for child := anchor.fLink; child != nil; child, child.next = child.next, nil {
|
|
||||||
}
|
|
||||||
anchor.idx = -1
|
anchor.idx = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,6 +373,8 @@ func (hd *HeaderDownload) ReadProgressFromDb(tx kv.RwTx) (err error) {
|
|||||||
func (hd *HeaderDownload) invalidateAnchor(anchor *Anchor, reason string) {
|
func (hd *HeaderDownload) invalidateAnchor(anchor *Anchor, reason string) {
|
||||||
log.Debug("Invalidating anchor", "height", anchor.blockHeight, "hash", anchor.parentHash, "reason", reason)
|
log.Debug("Invalidating anchor", "height", anchor.blockHeight, "hash", anchor.parentHash, "reason", reason)
|
||||||
hd.removeAnchor(anchor)
|
hd.removeAnchor(anchor)
|
||||||
|
for child := anchor.fLink; child != nil; child, child.next = child.next, nil {
|
||||||
|
}
|
||||||
hd.removeUpwards(anchor.fLink)
|
hd.removeUpwards(anchor.fLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -937,7 +937,6 @@ func (hd *HeaderDownload) ProcessHeader(sh ChainSegmentHeader, newBlock bool, pe
|
|||||||
peerID: peerID,
|
peerID: peerID,
|
||||||
blockHeight: sh.Number,
|
blockHeight: sh.Number,
|
||||||
}
|
}
|
||||||
link.next = anchor.fLink
|
|
||||||
anchor.fLink = link
|
anchor.fLink = link
|
||||||
hd.anchors[anchor.parentHash] = anchor
|
hd.anchors[anchor.parentHash] = anchor
|
||||||
heap.Push(hd.anchorQueue, anchor)
|
heap.Push(hd.anchorQueue, anchor)
|
||||||
|
Loading…
Reference in New Issue
Block a user