Skip to content

Commit aca066f

Browse files
committed
cmd/geth: drop upgradedb subcommand since it's unfeasible
This command was meant as a hackish way to upgrade our chain database way back when nobody cared for live updates and the size of the database along with its import times was small. With the current database weighing hundreds of GBs and processing times of many days, this command is just ludicrous.
1 parent 5ee0020 commit aca066f

2 files changed

Lines changed: 0 additions & 61 deletions

File tree

‎cmd/geth/chaincmd.go‎

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package main
1919
import (
2020
"fmt"
2121
"os"
22-
"path/filepath"
2322
"runtime"
2423
"strconv"
2524
"sync/atomic"
@@ -72,16 +71,6 @@ Requires a first argument of the file to write to.
7271
Optional second and third arguments control the first and
7372
last block to write. In this mode, the file will be appended
7473
if already existing.
75-
`,
76-
}
77-
upgradedbCommand = cli.Command{
78-
Action: upgradeDB,
79-
Name: "upgradedb",
80-
Usage: "Upgrade chainblock database",
81-
ArgsUsage: " ",
82-
Category: "BLOCKCHAIN COMMANDS",
83-
Description: `
84-
TODO: Please write this
8574
`,
8675
}
8776
removedbCommand = cli.Command{
@@ -255,49 +244,6 @@ func removeDB(ctx *cli.Context) error {
255244
return nil
256245
}
257246

258-
func upgradeDB(ctx *cli.Context) error {
259-
log.Info(fmt.Sprint("Upgrading blockchain database"))
260-
261-
stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
262-
chain, chainDb := utils.MakeChain(ctx, stack)
263-
bcVersion := core.GetBlockChainVersion(chainDb)
264-
if bcVersion == 0 {
265-
bcVersion = core.BlockChainVersion
266-
}
267-
268-
// Export the current chain.
269-
filename := fmt.Sprintf("blockchain_%d_%s.chain", bcVersion, time.Now().Format("20060102_150405"))
270-
exportFile := filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), filename)
271-
if err := utils.ExportChain(chain, exportFile); err != nil {
272-
utils.Fatalf("Unable to export chain for reimport %s", err)
273-
}
274-
chainDb.Close()
275-
if dir := dbDirectory(chainDb); dir != "" {
276-
os.RemoveAll(dir)
277-
}
278-
279-
// Import the chain file.
280-
chain, chainDb = utils.MakeChain(ctx, stack)
281-
core.WriteBlockChainVersion(chainDb, core.BlockChainVersion)
282-
err := utils.ImportChain(chain, exportFile)
283-
chainDb.Close()
284-
if err != nil {
285-
utils.Fatalf("Import error %v (a backup is made in %s, use the import command to import it)", err, exportFile)
286-
} else {
287-
os.Remove(exportFile)
288-
log.Info(fmt.Sprint("Import finished"))
289-
}
290-
return nil
291-
}
292-
293-
func dbDirectory(db ethdb.Database) string {
294-
ldb, ok := db.(*ethdb.LDBDatabase)
295-
if !ok {
296-
return ""
297-
}
298-
return ldb.Path()
299-
}
300-
301247
func dump(ctx *cli.Context) error {
302248
stack := makeFullNode(ctx)
303249
chain, chainDb := utils.MakeChain(ctx, stack)
@@ -329,9 +275,3 @@ func hashish(x string) bool {
329275
_, err := strconv.Atoi(x)
330276
return err != nil
331277
}
332-
333-
func closeAll(dbs ...ethdb.Database) {
334-
for _, db := range dbs {
335-
db.Close()
336-
}
337-
}

‎cmd/geth/main.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ func init() {
6565
initCommand,
6666
importCommand,
6767
exportCommand,
68-
upgradedbCommand,
6968
removedbCommand,
7069
dumpCommand,
7170
// See monitorcmd.go:

0 commit comments

Comments
 (0)