aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-07-19 23:41:58 +0800
committerGitHub <noreply@github.com>2016-07-19 23:41:58 +0800
commitfe564613870e268399b2919a04aa8c7e40c45dd8 (patch)
treed5f99eea927a25dde75471159109d8e26df074f3
parenta4c4125b1155d9276614029163b498a17643f0f2 (diff)
parent56efed71b51d8b2edbe000130903d6a5ecab84b3 (diff)
downloaddexon-fe564613870e268399b2919a04aa8c7e40c45dd8.tar
dexon-fe564613870e268399b2919a04aa8c7e40c45dd8.tar.gz
dexon-fe564613870e268399b2919a04aa8c7e40c45dd8.tar.bz2
dexon-fe564613870e268399b2919a04aa8c7e40c45dd8.tar.lz
dexon-fe564613870e268399b2919a04aa8c7e40c45dd8.tar.xz
dexon-fe564613870e268399b2919a04aa8c7e40c45dd8.tar.zst
dexon-fe564613870e268399b2919a04aa8c7e40c45dd8.zip
Merge pull request #2834 from zsfelfoldi/chaindb-upgrade-fix
eth: fixed chaindb upgrade
-rw-r--r--eth/db_upgrade.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/eth/db_upgrade.go b/eth/db_upgrade.go
index 12de60fe7..172bb0954 100644
--- a/eth/db_upgrade.go
+++ b/eth/db_upgrade.go
@@ -93,6 +93,9 @@ func upgradeSequentialKeys(db ethdb.Database) (stopFn func()) {
func upgradeSequentialCanonicalNumbers(db ethdb.Database, stopFn func() bool) (error, bool) {
prefix := []byte("block-num-")
it := db.(*ethdb.LDBDatabase).NewIterator()
+ defer func() {
+ it.Release()
+ }()
it.Seek(prefix)
cnt := 0
for bytes.HasPrefix(it.Key(), prefix) {
@@ -100,6 +103,9 @@ func upgradeSequentialCanonicalNumbers(db ethdb.Database, stopFn func() bool) (e
if len(keyPtr) < 20 {
cnt++
if cnt%100000 == 0 {
+ it.Release()
+ it = db.(*ethdb.LDBDatabase).NewIterator()
+ it.Seek(keyPtr)
glog.V(logger.Info).Infof("converting %d canonical numbers...", cnt)
}
number := big.NewInt(0).SetBytes(keyPtr[10:]).Uint64()
@@ -130,6 +136,9 @@ func upgradeSequentialCanonicalNumbers(db ethdb.Database, stopFn func() bool) (e
func upgradeSequentialBlocks(db ethdb.Database, stopFn func() bool) (error, bool) {
prefix := []byte("block-")
it := db.(*ethdb.LDBDatabase).NewIterator()
+ defer func() {
+ it.Release()
+ }()
it.Seek(prefix)
cnt := 0
for bytes.HasPrefix(it.Key(), prefix) {
@@ -137,6 +146,9 @@ func upgradeSequentialBlocks(db ethdb.Database, stopFn func() bool) (error, bool
if len(keyPtr) >= 38 {
cnt++
if cnt%10000 == 0 {
+ it.Release()
+ it = db.(*ethdb.LDBDatabase).NewIterator()
+ it.Seek(keyPtr)
glog.V(logger.Info).Infof("converting %d blocks...", cnt)
}
// convert header, body, td and block receipts
@@ -175,6 +187,7 @@ func upgradeSequentialBlocks(db ethdb.Database, stopFn func() bool) (error, bool
func upgradeSequentialOrphanedReceipts(db ethdb.Database, stopFn func() bool) (error, bool) {
prefix := []byte("receipts-block-")
it := db.(*ethdb.LDBDatabase).NewIterator()
+ defer it.Release()
it.Seek(prefix)
cnt := 0
for bytes.HasPrefix(it.Key(), prefix) {