mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 13:07:17 +00:00
Improvement to the trimTxs (#2215)
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
This commit is contained in:
parent
a79ed2fe0b
commit
ab685e90d9
@ -1972,6 +1972,24 @@ func trimTxs(chaindata string) error {
|
|||||||
toDelete.RemoveRange(body.BaseTxId, body.BaseTxId+uint64(body.TxAmount))
|
toDelete.RemoveRange(body.BaseTxId, body.BaseTxId+uint64(body.TxAmount))
|
||||||
}
|
}
|
||||||
fmt.Printf("Number of tx records to delete: %d\n", toDelete.GetCardinality())
|
fmt.Printf("Number of tx records to delete: %d\n", toDelete.GetCardinality())
|
||||||
|
// Takes 20min to iterate 1.4b
|
||||||
|
toDelete2 := roaring64.New()
|
||||||
|
var iterated int
|
||||||
|
for k, _, err := txs.First(); k != nil; k, _, err = txs.Next() {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
toDelete2.Add(binary.BigEndian.Uint64(k))
|
||||||
|
iterated++
|
||||||
|
if iterated%100_000_000 == 0 {
|
||||||
|
fmt.Printf("Iterated %d\n", iterated)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fmt.Printf("Number of tx records: %d\n", toDelete2.GetCardinality())
|
||||||
|
toDelete.And(toDelete2)
|
||||||
|
fmt.Printf("Number of tx records to delete: %d\n", toDelete.GetCardinality())
|
||||||
|
fmt.Printf("Roaring size: %d\n", toDelete.GetSizeInBytes())
|
||||||
|
|
||||||
iter := toDelete.Iterator()
|
iter := toDelete.Iterator()
|
||||||
for {
|
for {
|
||||||
var deleted int
|
var deleted int
|
||||||
|
Loading…
Reference in New Issue
Block a user