aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-02-28 19:41:02 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-02-28 19:41:02 +0800
commit46bcd9a92c747bd6f2f6f7377d39f3949469203c (patch)
tree60d65b744b69bbe477143ea444adba290653651a /eth
parentdbd88a1aa493d5f7bde5692c9649f795ad0bd7b0 (diff)
downloaddexon-46bcd9a92c747bd6f2f6f7377d39f3949469203c.tar
dexon-46bcd9a92c747bd6f2f6f7377d39f3949469203c.tar.gz
dexon-46bcd9a92c747bd6f2f6f7377d39f3949469203c.tar.bz2
dexon-46bcd9a92c747bd6f2f6f7377d39f3949469203c.tar.lz
dexon-46bcd9a92c747bd6f2f6f7377d39f3949469203c.tar.xz
dexon-46bcd9a92c747bd6f2f6f7377d39f3949469203c.tar.zst
dexon-46bcd9a92c747bd6f2f6f7377d39f3949469203c.zip
core, eth: drop database block splitting upgrader
Diffstat (limited to 'eth')
-rw-r--r--eth/backend.go3
-rw-r--r--eth/db_upgrade.go59
2 files changed, 0 insertions, 62 deletions
diff --git a/eth/backend.go b/eth/backend.go
index f20e4a509..c288b2557 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -176,9 +176,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
solcPath: config.SolcPath,
}
- if err := upgradeChainDatabase(chainDb); err != nil {
- return nil, err
- }
if err := addMipmapBloomBins(chainDb); err != nil {
return nil, err
}
diff --git a/eth/db_upgrade.go b/eth/db_upgrade.go
index 7038ebbbd..2a61af364 100644
--- a/eth/db_upgrade.go
+++ b/eth/db_upgrade.go
@@ -252,65 +252,6 @@ func upgradeSequentialBlockData(db ethdb.Database, hash []byte) error {
return nil
}
-// upgradeChainDatabase ensures that the chain database stores block split into
-// separate header and body entries.
-func upgradeChainDatabase(db ethdb.Database) error {
- // Short circuit if the head block is stored already as separate header and body
- data, err := db.Get([]byte("LastBlock"))
- if err != nil {
- return nil
- }
- head := common.BytesToHash(data)
-
- if block := core.GetBlockByHashOld(db, head); block == nil {
- return nil
- }
- // At least some of the database is still the old format, upgrade (skip the head block!)
- log.Info(fmt.Sprint("Old database detected, upgrading..."))
-
- if db, ok := db.(*ethdb.LDBDatabase); ok {
- blockPrefix := []byte("block-hash-")
- for it := db.NewIterator(); it.Next(); {
- // Skip anything other than a combined block
- if !bytes.HasPrefix(it.Key(), blockPrefix) {
- continue
- }
- // Skip the head block (merge last to signal upgrade completion)
- if bytes.HasSuffix(it.Key(), head.Bytes()) {
- continue
- }
- // Load the block, split and serialize (order!)
- block := core.GetBlockByHashOld(db, common.BytesToHash(bytes.TrimPrefix(it.Key(), blockPrefix)))
-
- if err := core.WriteTd(db, block.Hash(), block.NumberU64(), block.DeprecatedTd()); err != nil {
- return err
- }
- if err := core.WriteBody(db, block.Hash(), block.NumberU64(), block.Body()); err != nil {
- return err
- }
- if err := core.WriteHeader(db, block.Header()); err != nil {
- return err
- }
- if err := db.Delete(it.Key()); err != nil {
- return err
- }
- }
- // Lastly, upgrade the head block, disabling the upgrade mechanism
- current := core.GetBlockByHashOld(db, head)
-
- if err := core.WriteTd(db, current.Hash(), current.NumberU64(), current.DeprecatedTd()); err != nil {
- return err
- }
- if err := core.WriteBody(db, current.Hash(), current.NumberU64(), current.Body()); err != nil {
- return err
- }
- if err := core.WriteHeader(db, current.Header()); err != nil {
- return err
- }
- }
- return nil
-}
-
func addMipmapBloomBins(db ethdb.Database) (err error) {
const mipmapVersion uint = 2