mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
Remove unused upgradeDB command
This commit is contained in:
parent
d8f770ae10
commit
2b3c69137c
2 changed files with 1 additions and 54 deletions
|
|
@ -19,12 +19,12 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/syndtr/goleveldb/leveldb/util"
|
||||||
"github.com/ubiq/go-ubiq/cmd/utils"
|
"github.com/ubiq/go-ubiq/cmd/utils"
|
||||||
"github.com/ubiq/go-ubiq/common"
|
"github.com/ubiq/go-ubiq/common"
|
||||||
"github.com/ubiq/go-ubiq/console"
|
"github.com/ubiq/go-ubiq/console"
|
||||||
|
|
@ -35,7 +35,6 @@ import (
|
||||||
"github.com/ubiq/go-ubiq/logger"
|
"github.com/ubiq/go-ubiq/logger"
|
||||||
"github.com/ubiq/go-ubiq/logger/glog"
|
"github.com/ubiq/go-ubiq/logger/glog"
|
||||||
"github.com/ubiq/go-ubiq/trie"
|
"github.com/ubiq/go-ubiq/trie"
|
||||||
"github.com/syndtr/goleveldb/leveldb/util"
|
|
||||||
"gopkg.in/urfave/cli.v1"
|
"gopkg.in/urfave/cli.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -73,16 +72,6 @@ Requires a first argument of the file to write to.
|
||||||
Optional second and third arguments control the first and
|
Optional second and third arguments control the first and
|
||||||
last block to write. In this mode, the file will be appended
|
last block to write. In this mode, the file will be appended
|
||||||
if already existing.
|
if already existing.
|
||||||
`,
|
|
||||||
}
|
|
||||||
upgradedbCommand = cli.Command{
|
|
||||||
Action: upgradeDB,
|
|
||||||
Name: "upgradedb",
|
|
||||||
Usage: "Upgrade chainblock database",
|
|
||||||
ArgsUsage: " ",
|
|
||||||
Category: "BLOCKCHAIN COMMANDS",
|
|
||||||
Description: `
|
|
||||||
TODO: Please write this
|
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
removedbCommand = cli.Command{
|
removedbCommand = cli.Command{
|
||||||
|
|
@ -256,41 +245,6 @@ func removeDB(ctx *cli.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func upgradeDB(ctx *cli.Context) error {
|
|
||||||
glog.Infoln("Upgrading blockchain database")
|
|
||||||
|
|
||||||
stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
|
|
||||||
chain, chainDb := utils.MakeChain(ctx, stack)
|
|
||||||
bcVersion := core.GetBlockChainVersion(chainDb)
|
|
||||||
if bcVersion == 0 {
|
|
||||||
bcVersion = core.BlockChainVersion
|
|
||||||
}
|
|
||||||
|
|
||||||
// Export the current chain.
|
|
||||||
filename := fmt.Sprintf("blockchain_%d_%s.chain", bcVersion, time.Now().Format("20060102_150405"))
|
|
||||||
exportFile := filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), filename)
|
|
||||||
if err := utils.ExportChain(chain, exportFile); err != nil {
|
|
||||||
utils.Fatalf("Unable to export chain for reimport %s", err)
|
|
||||||
}
|
|
||||||
chainDb.Close()
|
|
||||||
if dir := dbDirectory(chainDb); dir != "" {
|
|
||||||
os.RemoveAll(dir)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Import the chain file.
|
|
||||||
chain, chainDb = utils.MakeChain(ctx, stack)
|
|
||||||
core.WriteBlockChainVersion(chainDb, core.BlockChainVersion)
|
|
||||||
err := utils.ImportChain(chain, exportFile)
|
|
||||||
chainDb.Close()
|
|
||||||
if err != nil {
|
|
||||||
utils.Fatalf("Import error %v (a backup is made in %s, use the import command to import it)", err, exportFile)
|
|
||||||
} else {
|
|
||||||
os.Remove(exportFile)
|
|
||||||
glog.Infoln("Import finished")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func dbDirectory(db ethdb.Database) string {
|
func dbDirectory(db ethdb.Database) string {
|
||||||
ldb, ok := db.(*ethdb.LDBDatabase)
|
ldb, ok := db.(*ethdb.LDBDatabase)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
@ -330,9 +284,3 @@ func hashish(x string) bool {
|
||||||
_, err := strconv.Atoi(x)
|
_, err := strconv.Atoi(x)
|
||||||
return err != nil
|
return err != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func closeAll(dbs ...ethdb.Database) {
|
|
||||||
for _, db := range dbs {
|
|
||||||
db.Close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,6 @@ func init() {
|
||||||
initCommand,
|
initCommand,
|
||||||
importCommand,
|
importCommand,
|
||||||
exportCommand,
|
exportCommand,
|
||||||
upgradedbCommand,
|
|
||||||
removedbCommand,
|
removedbCommand,
|
||||||
dumpCommand,
|
dumpCommand,
|
||||||
// See monitorcmd.go:
|
// See monitorcmd.go:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue