You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For a particular reason I want to delete blocks. But when I call rawdb.DeleteBlock it doesn't actually delete the old block. For example, the code below prints the same value for blockBefore and blockAfter (sans pointer differences). How do I actually delete blocks to save disk space?
func (bc *BlockChain) GetBlockByNumber(number uint64) *types.Block {
hash := rawdb.ReadCanonicalHash(bc.db, number)
if hash == (common.Hash{}) {
return nil
}
if number == 1000 {
blockBefore := bc.GetBlock(hash, number)
// clear from cache
present := bc.blockCache.Remove(hash)
bc.blockCache.Purge()
// try this way
rawdb.DeleteBlock(bc.db, hash, number)
// try using batches
batch := bc.db.NewBatch()
i := 0
for _, hash := range rawdb.ReadAllHashes(bc.db, number) {
i++
rawdb.DeleteBlock(batch, hash, number)
}
if err := batch.Write(); err != nil {
log.Error("Batch write got error", "err", err.Error())
}
blockAfter := bc.GetBlock(hash, number)
log.Info("GetHeader", "number", number, "blockBefore", blockBefore, "blockAfter", blockAfter, "present", present, "i", i)
}
return bc.GetBlock(hash, number)
}
Is there something obvious missing here? I see that sidechains are deleted in a similar manner.
The text was updated successfully, but these errors were encountered:
I'm guessing the block is somewhat old and hence stored in the freezer (not in leveldb). And right now freezer doesn't support deletion. But that feature is not far off: #23954
@karalabe I exported a range of blocks in an archive node with geth export and im trying to import this range in a read-only full node that I want to have this range of blocks with archive data... is this possible? while I import I get this message
INFO [12-05|02:35:21.235] Skipping batch as all blocks present batch=60 first=99299a..1a532a last=25ac15..f65ff1
For a particular reason I want to delete blocks. But when I call
rawdb.DeleteBlock
it doesn't actually delete the old block. For example, the code below prints the same value forblockBefore
andblockAfter
(sans pointer differences). How do I actually delete blocks to save disk space?Is there something obvious missing here? I see that sidechains are deleted in a similar manner.
The text was updated successfully, but these errors were encountered: