etherum & geth CLI

以太坊源码分析(二)geth CLI

Posted by minicool on February 2, 2018

前面介绍了以太坊生成的执行程序,作为主要执行程序geth,将作为分析的首要分析对象。首先从其输入命令标示分析开始。

geth

以太坊CLI(command-line interface)命令行客户端。

geth -help

NAME:
   geth - the go-ethereum command line interface

   Copyright 2013-2017 The go-ethereum Authors

USAGE:
   geth [options] command [command options] [arguments...]
   
VERSION:
   1.8.2-unstable-fa375955
   
COMMANDS:
   account     Manage accounts
   attach      Start an interactive JavaScript environment (connect to node)
   bug         opens a window to report a bug on the geth repo
   console     Start an interactive JavaScript environment
   copydb      Create a local chain from a target chaindata folder
   dump        Dump a specific block from storage
   dumpconfig  Show configuration values
   export      Export blockchain into file
   import      Import a blockchain file
   init        Bootstrap and initialize a new genesis block
   js          Execute the specified JavaScript files
   license     Display license information
   makecache   Generate ethash verification cache (for testing)
   makedag     Generate ethash mining DAG (for testing)
   monitor     Monitor and visualize node metrics
   removedb    Remove blockchain and state databases
   version     Print version numbers
   wallet      Manage Ethereum presale wallets
   help, h     Shows a list of commands or help for one command
   
ETHEREUM OPTIONS:
  --config value                                   TOML configuration file
  --datadir "/Users/Library/Ethereum"              Data directory for the databases and keystore
  --keystore                                       Directory for the keystore (default = inside the datadir)
  --nousb                                          Disables monitoring for and managing USB hardware wallets
  --networkid value                                Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby) (default: 1)
  --testnet                                        Ropsten network: pre-configured proof-of-work test network
  --rinkeby                                        Rinkeby network: pre-configured proof-of-authority test network
  --syncmode "fast"                                Blockchain sync mode ("fast", "full", or "light")
  --gcmode value                                   Blockchain garbage collection mode ("full", "archive") (default: "full")
  --ethstats value                                 Reporting URL of a ethstats service (nodename:secret@host:port)
  --identity value                                 Custom node name
  --lightserv value                                Maximum percentage of time allowed for serving LES requests (0-90) (default: 0)
  --lightpeers value                               Maximum number of LES client peers (default: 100)
  --lightkdf                                       Reduce key-derivation RAM & CPU usage at some expense of KDF strength
  

命令分析

account: 账户管理 attach: 连接到JavaScript交互环境 bug: 打开一个新窗口报告geth库的bug console: 开启一个JavaScript交互环境 copydb: 从一个目标莲数据文件夹拷贝到本地的链上 dump: 从存储中删除掉一个指定的区块 dumpconfig: 显示配置值 export: 导出区块链到文件 import: 从文件导入区块链 init: 通过一个向导初始化一个新的创世区块(genesis block!) js: 执行一个指定的JavaScript文件 license: 展示许可信息 makecache: 生成ethash校验缓存(用于测试),ethash是以太坊的计划性的PoW(工作量证明)算法。 makedag: 生成ethash挖矿DAG(用于测试),DAG是一个比特币的扩容方案 monitor: 监控使节点权值可视化 removedb: 除去区块链和状态数据库 version: 打印版本号 wallet: 管理以太坊预售钱包、 help: 帮助命令