blockchain: Delete block headers from old block index bucket.
As part of the migration to the new block index bucket, also delete the redundant data from the old bucket.
This commit is contained in:
parent
ad00e7ff82
commit
a4d22d8384
2 changed files with 10 additions and 2 deletions
|
@ -1192,7 +1192,7 @@ func (b *BlockChain) initChainState() error {
|
||||||
// number of nodes are already known, perform a single alloc
|
// number of nodes are already known, perform a single alloc
|
||||||
// for them versus a whole bunch of little ones to reduce
|
// for them versus a whole bunch of little ones to reduce
|
||||||
// pressure on the GC.
|
// pressure on the GC.
|
||||||
log.Infof("Loading block index. This might take a while...")
|
log.Infof("Loading block index...")
|
||||||
|
|
||||||
blockIndexBucket := dbTx.Metadata().Bucket(blockIndexBucketName)
|
blockIndexBucket := dbTx.Metadata().Bucket(blockIndexBucketName)
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,16 @@ func migrateBlockIndex(db database.DB) error {
|
||||||
"stored block %s", hash)
|
"stored block %s", hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write header to v2 bucket
|
||||||
key := blockIndexKey(&hash, height)
|
key := blockIndexKey(&hash, height)
|
||||||
return v2BlockIdxBucket.Put(key, headerBytes)
|
err := v2BlockIdxBucket.Put(key, headerBytes)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete header from v1 bucket
|
||||||
|
truncatedRow := blockRow[0:blockHdrOffset:blockHdrOffset]
|
||||||
|
return v1BlockIdxBucket.Put(hashBytes, truncatedRow)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue