chaincmd.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. // Copyright 2015 The go-ethereum Authors
  2. // This file is part of go-ethereum.
  3. //
  4. // go-ethereum is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // go-ethereum is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
  16. package main
  17. import (
  18. "encoding/json"
  19. "fmt"
  20. "os"
  21. "path/filepath"
  22. "runtime"
  23. "strconv"
  24. "sync/atomic"
  25. "time"
  26. "github.com/ethereum/go-ethereum/cmd/utils"
  27. "github.com/ethereum/go-ethereum/common"
  28. "github.com/ethereum/go-ethereum/console"
  29. "github.com/ethereum/go-ethereum/core"
  30. "github.com/ethereum/go-ethereum/core/rawdb"
  31. "github.com/ethereum/go-ethereum/core/state"
  32. "github.com/ethereum/go-ethereum/core/types"
  33. "github.com/ethereum/go-ethereum/eth/downloader"
  34. "github.com/ethereum/go-ethereum/event"
  35. "github.com/ethereum/go-ethereum/log"
  36. "github.com/ethereum/go-ethereum/metrics"
  37. "github.com/ethereum/go-ethereum/trie"
  38. "gopkg.in/urfave/cli.v1"
  39. )
  40. var (
  41. initCommand = cli.Command{
  42. Action: utils.MigrateFlags(initGenesis),
  43. Name: "init",
  44. Usage: "Bootstrap and initialize a new genesis block",
  45. ArgsUsage: "<genesisPath>",
  46. Flags: []cli.Flag{
  47. utils.DataDirFlag,
  48. },
  49. Category: "BLOCKCHAIN COMMANDS",
  50. Description: `
  51. The init command initializes a new genesis block and definition for the network.
  52. This is a destructive action and changes the network in which you will be
  53. participating.
  54. It expects the genesis file as argument.`,
  55. }
  56. dumpGenesisCommand = cli.Command{
  57. Action: utils.MigrateFlags(dumpGenesis),
  58. Name: "dumpgenesis",
  59. Usage: "Dumps genesis block JSON configuration to stdout",
  60. ArgsUsage: "",
  61. Flags: []cli.Flag{
  62. utils.DataDirFlag,
  63. },
  64. Category: "BLOCKCHAIN COMMANDS",
  65. Description: `
  66. The dumpgenesis command dumps the genesis block configuration in JSON format to stdout.`,
  67. }
  68. importCommand = cli.Command{
  69. Action: utils.MigrateFlags(importChain),
  70. Name: "import",
  71. Usage: "Import a blockchain file",
  72. ArgsUsage: "<filename> (<filename 2> ... <filename N>) ",
  73. Flags: []cli.Flag{
  74. utils.DataDirFlag,
  75. utils.CacheFlag,
  76. utils.SyncModeFlag,
  77. utils.GCModeFlag,
  78. utils.SnapshotFlag,
  79. utils.CacheDatabaseFlag,
  80. utils.CacheGCFlag,
  81. utils.MetricsEnabledFlag,
  82. utils.MetricsEnabledExpensiveFlag,
  83. utils.MetricsEnableInfluxDBFlag,
  84. utils.MetricsInfluxDBEndpointFlag,
  85. utils.MetricsInfluxDBDatabaseFlag,
  86. utils.MetricsInfluxDBUsernameFlag,
  87. utils.MetricsInfluxDBPasswordFlag,
  88. utils.MetricsInfluxDBTagsFlag,
  89. utils.TxLookupLimitFlag,
  90. },
  91. Category: "BLOCKCHAIN COMMANDS",
  92. Description: `
  93. The import command imports blocks from an RLP-encoded form. The form can be one file
  94. with several RLP-encoded blocks, or several files can be used.
  95. If only one file is used, import error will result in failure. If several files are used,
  96. processing will proceed even if an individual RLP-file import failure occurs.`,
  97. }
  98. exportCommand = cli.Command{
  99. Action: utils.MigrateFlags(exportChain),
  100. Name: "export",
  101. Usage: "Export blockchain into file",
  102. ArgsUsage: "<filename> [<blockNumFirst> <blockNumLast>]",
  103. Flags: []cli.Flag{
  104. utils.DataDirFlag,
  105. utils.CacheFlag,
  106. utils.SyncModeFlag,
  107. },
  108. Category: "BLOCKCHAIN COMMANDS",
  109. Description: `
  110. Requires a first argument of the file to write to.
  111. Optional second and third arguments control the first and
  112. last block to write. In this mode, the file will be appended
  113. if already existing. If the file ends with .gz, the output will
  114. be gzipped.`,
  115. }
  116. importPreimagesCommand = cli.Command{
  117. Action: utils.MigrateFlags(importPreimages),
  118. Name: "import-preimages",
  119. Usage: "Import the preimage database from an RLP stream",
  120. ArgsUsage: "<datafile>",
  121. Flags: []cli.Flag{
  122. utils.DataDirFlag,
  123. utils.CacheFlag,
  124. utils.SyncModeFlag,
  125. },
  126. Category: "BLOCKCHAIN COMMANDS",
  127. Description: `
  128. The import-preimages command imports hash preimages from an RLP encoded stream.`,
  129. }
  130. exportPreimagesCommand = cli.Command{
  131. Action: utils.MigrateFlags(exportPreimages),
  132. Name: "export-preimages",
  133. Usage: "Export the preimage database into an RLP stream",
  134. ArgsUsage: "<dumpfile>",
  135. Flags: []cli.Flag{
  136. utils.DataDirFlag,
  137. utils.CacheFlag,
  138. utils.SyncModeFlag,
  139. },
  140. Category: "BLOCKCHAIN COMMANDS",
  141. Description: `
  142. The export-preimages command export hash preimages to an RLP encoded stream`,
  143. }
  144. copydbCommand = cli.Command{
  145. Action: utils.MigrateFlags(copyDb),
  146. Name: "copydb",
  147. Usage: "Create a local chain from a target chaindata folder",
  148. ArgsUsage: "<sourceChaindataDir>",
  149. Flags: []cli.Flag{
  150. utils.DataDirFlag,
  151. utils.CacheFlag,
  152. utils.SyncModeFlag,
  153. utils.FakePoWFlag,
  154. utils.RopstenFlag,
  155. utils.RinkebyFlag,
  156. utils.TxLookupLimitFlag,
  157. utils.GoerliFlag,
  158. utils.LegacyTestnetFlag,
  159. },
  160. Category: "BLOCKCHAIN COMMANDS",
  161. Description: `
  162. The first argument must be the directory containing the blockchain to download from`,
  163. }
  164. removedbCommand = cli.Command{
  165. Action: utils.MigrateFlags(removeDB),
  166. Name: "removedb",
  167. Usage: "Remove blockchain and state databases",
  168. ArgsUsage: " ",
  169. Flags: []cli.Flag{
  170. utils.DataDirFlag,
  171. },
  172. Category: "BLOCKCHAIN COMMANDS",
  173. Description: `
  174. Remove blockchain and state databases`,
  175. }
  176. dumpCommand = cli.Command{
  177. Action: utils.MigrateFlags(dump),
  178. Name: "dump",
  179. Usage: "Dump a specific block from storage",
  180. ArgsUsage: "[<blockHash> | <blockNum>]...",
  181. Flags: []cli.Flag{
  182. utils.DataDirFlag,
  183. utils.CacheFlag,
  184. utils.SyncModeFlag,
  185. utils.IterativeOutputFlag,
  186. utils.ExcludeCodeFlag,
  187. utils.ExcludeStorageFlag,
  188. utils.IncludeIncompletesFlag,
  189. },
  190. Category: "BLOCKCHAIN COMMANDS",
  191. Description: `
  192. The arguments are interpreted as block numbers or hashes.
  193. Use "ethereum dump 0" to dump the genesis block.`,
  194. }
  195. inspectCommand = cli.Command{
  196. Action: utils.MigrateFlags(inspect),
  197. Name: "inspect",
  198. Usage: "Inspect the storage size for each type of data in the database",
  199. ArgsUsage: " ",
  200. Flags: []cli.Flag{
  201. utils.DataDirFlag,
  202. utils.AncientFlag,
  203. utils.CacheFlag,
  204. utils.RopstenFlag,
  205. utils.RinkebyFlag,
  206. utils.GoerliFlag,
  207. utils.LegacyTestnetFlag,
  208. utils.SyncModeFlag,
  209. },
  210. Category: "BLOCKCHAIN COMMANDS",
  211. }
  212. )
  213. // initGenesis will initialise the given JSON format genesis file and writes it as
  214. // the zero'd block (i.e. genesis) or will fail hard if it can't succeed.
  215. func initGenesis(ctx *cli.Context) error {
  216. // Make sure we have a valid genesis JSON
  217. genesisPath := ctx.Args().First()
  218. if len(genesisPath) == 0 {
  219. utils.Fatalf("Must supply path to genesis JSON file")
  220. }
  221. file, err := os.Open(genesisPath)
  222. if err != nil {
  223. utils.Fatalf("Failed to read genesis file: %v", err)
  224. }
  225. defer file.Close()
  226. genesis := new(core.Genesis)
  227. if err := json.NewDecoder(file).Decode(genesis); err != nil {
  228. utils.Fatalf("invalid genesis file: %v", err)
  229. }
  230. // Open an initialise both full and light databases
  231. stack := makeFullNode(ctx)
  232. defer stack.Close()
  233. for _, name := range []string{"chaindata", "lightchaindata"} {
  234. chaindb, err := stack.OpenDatabase(name, 0, 0, "")
  235. if err != nil {
  236. utils.Fatalf("Failed to open database: %v", err)
  237. }
  238. _, hash, err := core.SetupGenesisBlock(chaindb, genesis)
  239. if err != nil {
  240. utils.Fatalf("Failed to write genesis block: %v", err)
  241. }
  242. chaindb.Close()
  243. log.Info("Successfully wrote genesis state", "database", name, "hash", hash)
  244. }
  245. return nil
  246. }
  247. func dumpGenesis(ctx *cli.Context) error {
  248. genesis := utils.MakeGenesis(ctx)
  249. if genesis == nil {
  250. genesis = core.DefaultGenesisBlock()
  251. }
  252. if err := json.NewEncoder(os.Stdout).Encode(genesis); err != nil {
  253. utils.Fatalf("could not encode genesis")
  254. }
  255. return nil
  256. }
  257. func importChain(ctx *cli.Context) error {
  258. if len(ctx.Args()) < 1 {
  259. utils.Fatalf("This command requires an argument.")
  260. }
  261. // Start metrics export if enabled
  262. utils.SetupMetrics(ctx)
  263. // Start system runtime metrics collection
  264. go metrics.CollectProcessMetrics(3 * time.Second)
  265. stack := makeFullNode(ctx)
  266. defer stack.Close()
  267. chain, db := utils.MakeChain(ctx, stack, false)
  268. defer db.Close()
  269. // Start periodically gathering memory profiles
  270. var peakMemAlloc, peakMemSys uint64
  271. go func() {
  272. stats := new(runtime.MemStats)
  273. for {
  274. runtime.ReadMemStats(stats)
  275. if atomic.LoadUint64(&peakMemAlloc) < stats.Alloc {
  276. atomic.StoreUint64(&peakMemAlloc, stats.Alloc)
  277. }
  278. if atomic.LoadUint64(&peakMemSys) < stats.Sys {
  279. atomic.StoreUint64(&peakMemSys, stats.Sys)
  280. }
  281. time.Sleep(5 * time.Second)
  282. }
  283. }()
  284. // Import the chain
  285. start := time.Now()
  286. if len(ctx.Args()) == 1 {
  287. if err := utils.ImportChain(chain, ctx.Args().First()); err != nil {
  288. log.Error("Import error", "err", err)
  289. }
  290. } else {
  291. for _, arg := range ctx.Args() {
  292. if err := utils.ImportChain(chain, arg); err != nil {
  293. log.Error("Import error", "file", arg, "err", err)
  294. }
  295. }
  296. }
  297. chain.Stop()
  298. fmt.Printf("Import done in %v.\n\n", time.Since(start))
  299. // Output pre-compaction stats mostly to see the import trashing
  300. stats, err := db.Stat("leveldb.stats")
  301. if err != nil {
  302. utils.Fatalf("Failed to read database stats: %v", err)
  303. }
  304. fmt.Println(stats)
  305. ioStats, err := db.Stat("leveldb.iostats")
  306. if err != nil {
  307. utils.Fatalf("Failed to read database iostats: %v", err)
  308. }
  309. fmt.Println(ioStats)
  310. // Print the memory statistics used by the importing
  311. mem := new(runtime.MemStats)
  312. runtime.ReadMemStats(mem)
  313. fmt.Printf("Object memory: %.3f MB current, %.3f MB peak\n", float64(mem.Alloc)/1024/1024, float64(atomic.LoadUint64(&peakMemAlloc))/1024/1024)
  314. fmt.Printf("System memory: %.3f MB current, %.3f MB peak\n", float64(mem.Sys)/1024/1024, float64(atomic.LoadUint64(&peakMemSys))/1024/1024)
  315. fmt.Printf("Allocations: %.3f million\n", float64(mem.Mallocs)/1000000)
  316. fmt.Printf("GC pause: %v\n\n", time.Duration(mem.PauseTotalNs))
  317. if ctx.GlobalBool(utils.NoCompactionFlag.Name) {
  318. return nil
  319. }
  320. // Compact the entire database to more accurately measure disk io and print the stats
  321. start = time.Now()
  322. fmt.Println("Compacting entire database...")
  323. if err = db.Compact(nil, nil); err != nil {
  324. utils.Fatalf("Compaction failed: %v", err)
  325. }
  326. fmt.Printf("Compaction done in %v.\n\n", time.Since(start))
  327. stats, err = db.Stat("leveldb.stats")
  328. if err != nil {
  329. utils.Fatalf("Failed to read database stats: %v", err)
  330. }
  331. fmt.Println(stats)
  332. ioStats, err = db.Stat("leveldb.iostats")
  333. if err != nil {
  334. utils.Fatalf("Failed to read database iostats: %v", err)
  335. }
  336. fmt.Println(ioStats)
  337. return nil
  338. }
  339. func exportChain(ctx *cli.Context) error {
  340. if len(ctx.Args()) < 1 {
  341. utils.Fatalf("This command requires an argument.")
  342. }
  343. stack := makeFullNode(ctx)
  344. defer stack.Close()
  345. chain, _ := utils.MakeChain(ctx, stack, true)
  346. start := time.Now()
  347. var err error
  348. fp := ctx.Args().First()
  349. if len(ctx.Args()) < 3 {
  350. err = utils.ExportChain(chain, fp)
  351. } else {
  352. // This can be improved to allow for numbers larger than 9223372036854775807
  353. first, ferr := strconv.ParseInt(ctx.Args().Get(1), 10, 64)
  354. last, lerr := strconv.ParseInt(ctx.Args().Get(2), 10, 64)
  355. if ferr != nil || lerr != nil {
  356. utils.Fatalf("Export error in parsing parameters: block number not an integer\n")
  357. }
  358. if first < 0 || last < 0 {
  359. utils.Fatalf("Export error: block number must be greater than 0\n")
  360. }
  361. err = utils.ExportAppendChain(chain, fp, uint64(first), uint64(last))
  362. }
  363. if err != nil {
  364. utils.Fatalf("Export error: %v\n", err)
  365. }
  366. fmt.Printf("Export done in %v\n", time.Since(start))
  367. return nil
  368. }
  369. // importPreimages imports preimage data from the specified file.
  370. func importPreimages(ctx *cli.Context) error {
  371. if len(ctx.Args()) < 1 {
  372. utils.Fatalf("This command requires an argument.")
  373. }
  374. stack := makeFullNode(ctx)
  375. defer stack.Close()
  376. db := utils.MakeChainDatabase(ctx, stack)
  377. start := time.Now()
  378. if err := utils.ImportPreimages(db, ctx.Args().First()); err != nil {
  379. utils.Fatalf("Import error: %v\n", err)
  380. }
  381. fmt.Printf("Import done in %v\n", time.Since(start))
  382. return nil
  383. }
  384. // exportPreimages dumps the preimage data to specified json file in streaming way.
  385. func exportPreimages(ctx *cli.Context) error {
  386. if len(ctx.Args()) < 1 {
  387. utils.Fatalf("This command requires an argument.")
  388. }
  389. stack := makeFullNode(ctx)
  390. defer stack.Close()
  391. db := utils.MakeChainDatabase(ctx, stack)
  392. start := time.Now()
  393. if err := utils.ExportPreimages(db, ctx.Args().First()); err != nil {
  394. utils.Fatalf("Export error: %v\n", err)
  395. }
  396. fmt.Printf("Export done in %v\n", time.Since(start))
  397. return nil
  398. }
  399. func copyDb(ctx *cli.Context) error {
  400. // Ensure we have a source chain directory to copy
  401. if len(ctx.Args()) < 1 {
  402. utils.Fatalf("Source chaindata directory path argument missing")
  403. }
  404. if len(ctx.Args()) < 2 {
  405. utils.Fatalf("Source ancient chain directory path argument missing")
  406. }
  407. // Initialize a new chain for the running node to sync into
  408. stack := makeFullNode(ctx)
  409. defer stack.Close()
  410. chain, chainDb := utils.MakeChain(ctx, stack, false)
  411. syncMode := *utils.GlobalTextMarshaler(ctx, utils.SyncModeFlag.Name).(*downloader.SyncMode)
  412. var syncBloom *trie.SyncBloom
  413. if syncMode == downloader.FastSync {
  414. syncBloom = trie.NewSyncBloom(uint64(ctx.GlobalInt(utils.CacheFlag.Name)/2), chainDb)
  415. }
  416. dl := downloader.New(0, chainDb, syncBloom, new(event.TypeMux), chain, nil, nil)
  417. // Create a source peer to satisfy downloader requests from
  418. db, err := rawdb.NewLevelDBDatabaseWithFreezer(ctx.Args().First(), ctx.GlobalInt(utils.CacheFlag.Name)/2, 256, ctx.Args().Get(1), "")
  419. if err != nil {
  420. return err
  421. }
  422. hc, err := core.NewHeaderChain(db, chain.Config(), chain.Engine(), func() bool { return false })
  423. if err != nil {
  424. return err
  425. }
  426. peer := downloader.NewFakePeer("local", db, hc, dl)
  427. if err = dl.RegisterPeer("local", 63, peer); err != nil {
  428. return err
  429. }
  430. // Synchronise with the simulated peer
  431. start := time.Now()
  432. currentHeader := hc.CurrentHeader()
  433. if err = dl.Synchronise("local", currentHeader.Hash(), hc.GetTd(currentHeader.Hash(), currentHeader.Number.Uint64()), syncMode); err != nil {
  434. return err
  435. }
  436. for dl.Synchronising() {
  437. time.Sleep(10 * time.Millisecond)
  438. }
  439. fmt.Printf("Database copy done in %v\n", time.Since(start))
  440. // Compact the entire database to remove any sync overhead
  441. start = time.Now()
  442. fmt.Println("Compacting entire database...")
  443. if err = db.Compact(nil, nil); err != nil {
  444. utils.Fatalf("Compaction failed: %v", err)
  445. }
  446. fmt.Printf("Compaction done in %v.\n\n", time.Since(start))
  447. return nil
  448. }
  449. func removeDB(ctx *cli.Context) error {
  450. stack, config := makeConfigNode(ctx)
  451. // Remove the full node state database
  452. path := stack.ResolvePath("chaindata")
  453. if common.FileExist(path) {
  454. confirmAndRemoveDB(path, "full node state database")
  455. } else {
  456. log.Info("Full node state database missing", "path", path)
  457. }
  458. // Remove the full node ancient database
  459. path = config.Eth.DatabaseFreezer
  460. switch {
  461. case path == "":
  462. path = filepath.Join(stack.ResolvePath("chaindata"), "ancient")
  463. case !filepath.IsAbs(path):
  464. path = config.Node.ResolvePath(path)
  465. }
  466. if common.FileExist(path) {
  467. confirmAndRemoveDB(path, "full node ancient database")
  468. } else {
  469. log.Info("Full node ancient database missing", "path", path)
  470. }
  471. // Remove the light node database
  472. path = stack.ResolvePath("lightchaindata")
  473. if common.FileExist(path) {
  474. confirmAndRemoveDB(path, "light node database")
  475. } else {
  476. log.Info("Light node database missing", "path", path)
  477. }
  478. return nil
  479. }
  480. // confirmAndRemoveDB prompts the user for a last confirmation and removes the
  481. // folder if accepted.
  482. func confirmAndRemoveDB(database string, kind string) {
  483. confirm, err := console.Stdin.PromptConfirm(fmt.Sprintf("Remove %s (%s)?", kind, database))
  484. switch {
  485. case err != nil:
  486. utils.Fatalf("%v", err)
  487. case !confirm:
  488. log.Info("Database deletion skipped", "path", database)
  489. default:
  490. start := time.Now()
  491. filepath.Walk(database, func(path string, info os.FileInfo, err error) error {
  492. // If we're at the top level folder, recurse into
  493. if path == database {
  494. return nil
  495. }
  496. // Delete all the files, but not subfolders
  497. if !info.IsDir() {
  498. os.Remove(path)
  499. return nil
  500. }
  501. return filepath.SkipDir
  502. })
  503. log.Info("Database successfully deleted", "path", database, "elapsed", common.PrettyDuration(time.Since(start)))
  504. }
  505. }
  506. func dump(ctx *cli.Context) error {
  507. stack := makeFullNode(ctx)
  508. defer stack.Close()
  509. chain, chainDb := utils.MakeChain(ctx, stack, true)
  510. defer chainDb.Close()
  511. for _, arg := range ctx.Args() {
  512. var block *types.Block
  513. if hashish(arg) {
  514. block = chain.GetBlockByHash(common.HexToHash(arg))
  515. } else {
  516. num, _ := strconv.Atoi(arg)
  517. block = chain.GetBlockByNumber(uint64(num))
  518. }
  519. if block == nil {
  520. fmt.Println("{}")
  521. utils.Fatalf("block not found")
  522. } else {
  523. state, err := state.New(block.Root(), state.NewDatabase(chainDb), nil)
  524. if err != nil {
  525. utils.Fatalf("could not create new state: %v", err)
  526. }
  527. excludeCode := ctx.Bool(utils.ExcludeCodeFlag.Name)
  528. excludeStorage := ctx.Bool(utils.ExcludeStorageFlag.Name)
  529. includeMissing := ctx.Bool(utils.IncludeIncompletesFlag.Name)
  530. if ctx.Bool(utils.IterativeOutputFlag.Name) {
  531. state.IterativeDump(excludeCode, excludeStorage, !includeMissing, json.NewEncoder(os.Stdout))
  532. } else {
  533. if includeMissing {
  534. fmt.Printf("If you want to include accounts with missing preimages, you need iterative output, since" +
  535. " otherwise the accounts will overwrite each other in the resulting mapping.")
  536. }
  537. fmt.Printf("%v %s\n", includeMissing, state.Dump(excludeCode, excludeStorage, false))
  538. }
  539. }
  540. }
  541. return nil
  542. }
  543. func inspect(ctx *cli.Context) error {
  544. node, _ := makeConfigNode(ctx)
  545. defer node.Close()
  546. _, chainDb := utils.MakeChain(ctx, node, true)
  547. defer chainDb.Close()
  548. return rawdb.InspectDatabase(chainDb)
  549. }
  550. // hashish returns true for strings that look like hashes.
  551. func hashish(x string) bool {
  552. _, err := strconv.Atoi(x)
  553. return err != nil
  554. }