diff --git a/blockchain/chainio.go b/blockchain/chainio.go index 51216f56..85c910ab 100644 --- a/blockchain/chainio.go +++ b/blockchain/chainio.go @@ -1192,7 +1192,7 @@ func (b *BlockChain) initChainState() error { // number of nodes are already known, perform a single alloc // for them versus a whole bunch of little ones to reduce // pressure on the GC. - log.Infof("Loading block index. This might take a while...") + log.Infof("Loading block index...") blockIndexBucket := dbTx.Metadata().Bucket(blockIndexBucketName) diff --git a/blockchain/upgrade.go b/blockchain/upgrade.go index 60e8a897..f980d015 100644 --- a/blockchain/upgrade.go +++ b/blockchain/upgrade.go @@ -72,8 +72,16 @@ func migrateBlockIndex(db database.DB) error { "stored block %s", hash) } + // Write header to v2 bucket 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 {