@@ -21,7 +21,6 @@ import (
2121 "fmt"
2222 "io/ioutil"
2323 "os"
24- "path/filepath"
2524 "runtime"
2625 "strconv"
2726 "sync/atomic"
@@ -30,16 +29,12 @@ import (
3029 "github.com/ethereum/go-ethereum/cmd/utils"
3130 "github.com/ethereum/go-ethereum/common"
3231 "github.com/ethereum/go-ethereum/core"
33- "github.com/ethereum/go-ethereum/core/rawdb"
3432 "github.com/ethereum/go-ethereum/core/state"
3533 "github.com/ethereum/go-ethereum/core/types"
36- "github.com/ethereum/go-ethereum/eth/downloader"
37- "github.com/ethereum/go-ethereum/event"
3834 "github.com/ethereum/go-ethereum/log"
3935 "github.com/ethereum/go-ethereum/metrics"
4036 "github.com/ethereum/go-ethereum/params"
4137 "github.com/ethereum/go-ethereum/params/types/genesisT"
42- "github.com/ethereum/go-ethereum/trie"
4338 "gopkg.in/urfave/cli.v1"
4439)
4540
@@ -152,32 +147,6 @@ be gzipped.`,
152147 Category : "BLOCKCHAIN COMMANDS" ,
153148 Description : `
154149The export-preimages command export hash preimages to an RLP encoded stream` ,
155- }
156- copydbCommand = cli.Command {
157- Action : utils .MigrateFlags (copyDb ),
158- Name : "copydb" ,
159- Usage : "Create a local chain from a target chaindata folder" ,
160- ArgsUsage : "<sourceChaindataDir>" ,
161- Flags : []cli.Flag {
162- utils .DataDirFlag ,
163- utils .AncientFlag ,
164- utils .AncientRPCFlag ,
165- utils .CacheFlag ,
166- utils .SyncModeFlag ,
167- utils .FakePoWFlag ,
168- utils .MainnetFlag ,
169- utils .ClassicFlag ,
170- utils .MordorFlag ,
171- utils .KottiFlag ,
172- utils .RinkebyFlag ,
173- utils .GoerliFlag ,
174- utils .YoloV3Flag ,
175- utils .TxLookupLimitFlag ,
176- },
177- Category : "BLOCKCHAIN COMMANDS" ,
178- Description : `
179- The first argument must be the chaindata directory containing the blockchain to download from.
180- The second argument can be the ancient chain directory path (default = inside chaindata).` ,
181150 }
182151 dumpCommand = cli.Command {
183152 Action : utils .MigrateFlags (dump ),
@@ -401,65 +370,6 @@ func exportPreimages(ctx *cli.Context) error {
401370 return nil
402371}
403372
404- func copyDb (ctx * cli.Context ) error {
405- // Ensure we have a source chain directory to copy
406- if len (ctx .Args ()) < 1 {
407- utils .Fatalf ("Source chaindata directory path argument missing" )
408- }
409- root := ctx .Args ().First ()
410- freezer := filepath .Join (root , "ancient" )
411- // Ancient freeer path can be set as a second argument
412- if len (ctx .Args ()) == 2 {
413- freezer = ctx .Args ().Get (1 )
414- }
415- // Initialize a new chain for the running node to sync into
416- stack , _ := makeConfigNode (ctx )
417- defer stack .Close ()
418-
419- chain , chainDb := utils .MakeChain (ctx , stack , false )
420- syncMode := * utils .GlobalTextMarshaler (ctx , utils .SyncModeFlag .Name ).(* downloader.SyncMode )
421-
422- var syncBloom * trie.SyncBloom
423- if syncMode == downloader .FastSync {
424- syncBloom = trie .NewSyncBloom (uint64 (ctx .GlobalInt (utils .CacheFlag .Name )/ 2 ), chainDb )
425- }
426- dl := downloader .New (0 , chainDb , syncBloom , new (event.TypeMux ), chain , nil , nil )
427-
428- // Create a source peer to satisfy downloader requests from
429- db , err := rawdb .NewLevelDBDatabaseWithFreezer (root , ctx .GlobalInt (utils .CacheFlag .Name )/ 2 , 256 , freezer , "" )
430- if err != nil {
431- return err
432- }
433- hc , err := core .NewHeaderChain (db , chain .Config (), chain .Engine (), func () bool { return false })
434- if err != nil {
435- return err
436- }
437- peer := downloader .NewFakePeer ("local" , db , hc , dl )
438- if err = dl .RegisterPeer ("local" , 63 , peer ); err != nil {
439- return err
440- }
441- // Synchronise with the simulated peer
442- start := time .Now ()
443-
444- currentHeader := hc .CurrentHeader ()
445- if err = dl .Synchronise ("local" , currentHeader .Hash (), hc .GetTd (currentHeader .Hash (), currentHeader .Number .Uint64 ()), syncMode ); err != nil {
446- return err
447- }
448- for dl .Synchronising () {
449- time .Sleep (10 * time .Millisecond )
450- }
451- fmt .Printf ("Database copy done in %v\n " , time .Since (start ))
452-
453- // Compact the entire database to remove any sync overhead
454- start = time .Now ()
455- fmt .Println ("Compacting entire database..." )
456- if err = db .Compact (nil , nil ); err != nil {
457- utils .Fatalf ("Compaction failed: %v" , err )
458- }
459- fmt .Printf ("Compaction done in %v.\n \n " , time .Since (start ))
460- return nil
461- }
462-
463373func dump (ctx * cli.Context ) error {
464374 stack , _ := makeConfigNode (ctx )
465375 defer stack .Close ()
0 commit comments