区块链研习社程序员技术交流互联网科技

区块链系列教程——geth命令详解

2019-05-02  本文已影响71人  程序员Sunny

本文是区块链系列的第二篇,上一篇区块链系列教程——创建属于自己的区块链大概介绍了区块链的基本内容,并且使用geth客户端创建了私链,给了各位读者较为直观的感受。本文简单介绍geth命令,这对后面的教程来说是一个基础。

geth用法简介

在安装有geth的环境下,使用命令即可查看geth的所有操作参数:

geth -help

其用法为:

geth [options] command [command options] [arguments...]

geth命令简介

其中,command部分主要有:

   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
   export-preimages  Export the preimage database into an RLP stream
   import            Import a blockchain file
   import-preimages  Import the preimage database from an RLP stream
   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

此处主要讲解部分高频使用的命令。

1. account

该命令用于对节点中的账户进行管理,比如使用命令创建新的账户:

hadoop@tomcat:~/blockchain$ geth account new
INFO [05-02|22:34:35.822] Maximum peer count                       ETH=25 LES=0 total=25
Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase: 
Repeat passphrase: 
Address: {0661ae6f3586b5d06f72631d40b576572df58cf8}

比如列出所创建的所有账户信息:

hadoop@tomcat:~/blockchain$ geth account list
INFO [05-02|22:36:56.617] Maximum peer count                       ETH=25 LES=0 total=25
Account #0: {39270dca851f877e25de0b3dd2bc362a56c93d14} keystore:///home/hadoop/.ethereum/keystore/UTC--2018-11-08T07-51-54.537198312Z--39270dca851f877e25de0b3dd2bc362a56c93d14
Account #1: {3ad29039e3a403bec76f72f49df9c695132b7413} keystore:///home/hadoop/.ethereum/keystore/UTC--2019-03-08T03-01-21.222439496Z--3ad29039e3a403bec76f72f49df9c695132b7413
Account #2: {76522ed9030ecdbc2adcf9db101ee351841a026d} keystore:///home/hadoop/.ethereum/keystore/UTC--2019-03-08T03-02-18.142740162Z--76522ed9030ecdbc2adcf9db101ee351841a026d
Account #3: {0eb26f508cb4366cca769f5b42a2db53ac3411bc} keystore:///home/hadoop/.ethereum/keystore/UTC--2019-03-08T03-06-41.861044859Z--0eb26f508cb4366cca769f5b42a2db53ac3411bc
Account #4: {03b753d082b2c65054b5ac0a624c3c206a8384ce} keystore:///home/hadoop/.ethereum/keystore/UTC--2019-03-08T13-43-43.058685461Z--03b753d082b2c65054b5ac0a624c3c206a8384ce
Account #5: {69e5860b1b7b2fbbb5e99c856ccf1daa3d99cceb} keystore:///home/hadoop/.ethereum/keystore/UTC--2019-03-08T14-36-59.127976359Z--69e5860b1b7b2fbbb5e99c856ccf1daa3d99cceb
Account #6: {49fc0574f7e149a5e772ca0144df1177af56a544} keystore:///home/hadoop/.ethereum/keystore/UTC--2019-03-08T14-42-36.761539434Z--49fc0574f7e149a5e772ca0144df1177af56a544
Account #7: {36606041ff9727c15337aa68493c62a9f4fe721c} keystore:///home/hadoop/.ethereum/keystore/UTC--2019-03-08T14-45-17.989230302Z--36606041ff9727c15337aa68493c62a9f4fe721c
Account #8: {c20302e3423fdc2d451c1f989978c82ddcb3d25d} keystore:///home/hadoop/.ethereum/keystore/UTC--2019-03-08T14-49-35.136771402Z--c20302e3423fdc2d451c1f989978c82ddcb3d25d
Account #9: {0ee10994abc4ad567ae660c38dece6b66316e8f2} keystore:///home/hadoop/.ethereum/keystore/UTC--2019-03-09T03-02-59.629189896Z--0ee10994abc4ad567ae660c38dece6b66316e8f2
Account #10: {dfad42736734d1e943cb3390ebab0f3f9b6cd956} keystore:///home/hadoop/.ethereum/keystore/UTC--2019-03-09T03-08-56.185678319Z--dfad42736734d1e943cb3390ebab0f3f9b6cd956
Account #11: {b1d16776a90ab4acfa12c253821d39f4e72c8ede} keystore:///home/hadoop/.ethereum/keystore/UTC--2019-03-09T03-10-18.698606526Z--b1d16776a90ab4acfa12c253821d39f4e72c8ede
Account #12: {0661ae6f3586b5d06f72631d40b576572df58cf8} keystore:///home/hadoop/.ethereum/keystore/UTC--2019-05-02T14-35-39.394844103Z--0661ae6f3586b5d06f72631d40b576572df58cf8

2. attach

attach命令主要用于连接到一个正在运行的节点,并且会打开一个控制台用于交互:

hadoop@tomcat:~/blockchain/test$ ls
geth  geth.ipc  history  keystore
hadoop@tomcat:~/blockchain/test$ geth attach geth.ipc 
Welcome to the Geth JavaScript console!

instance: Geth/v1.8.17-stable-8bbe7207/linux-amd64/go1.10
coinbase: 0x6393bb737b95465ccd9e4597df0647cdcd09775f
at block: 11 (Wed, 01 May 2019 21:40:53 CST)
 datadir: /home/hadoop/blockchain/test
 modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> 

3. console

console命令用于打开控制台用于交互,与attach有所不同,console一般是在区块链运行时打开,而attach是在节点运行的前提下连接到节点进行交互,两者可以并存。该命令具体用法在上一篇已经展示:

hadoop@tomcat:~/blockchain$ geth --datadir test/ --networkid 10 console
INFO [05-02|22:38:40.954] Maximum peer count                       ETH=25 LES=0 total=25
INFO [05-02|22:38:40.955] Starting peer-to-peer node               instance=Geth/v1.8.17-stable-8bbe7207/linux-amd64/go1.10
INFO [05-02|22:38:40.955] Allocated cache and file handles         database=/home/hadoop/blockchain/test/geth/chaindata cache=768 handles=512
INFO [05-02|22:38:41.045] Initialised chain configuration          config="{ChainID: 10 Homestead: 0 DAO: <nil> DAOSupport: false EIP150: <nil> EIP155: 0 EIP158: 0 Byzantium: <nil> Constantinople: <nil> Engine: unknown}"
INFO [05-02|22:38:41.045] Disk storage enabled for ethash caches   dir=/home/hadoop/blockchain/test/geth/ethash count=3
INFO [05-02|22:38:41.045] Disk storage enabled for ethash DAGs     dir=/home/hadoop/.ethash                     count=2
INFO [05-02|22:38:41.045] Initialising Ethereum protocol           versions="[63 62]" network=10
INFO [05-02|22:38:41.047] Loaded most recent local header          number=11 hash=4c92d8…336e91 td=382991890 age=1d57m48s
INFO [05-02|22:38:41.047] Loaded most recent local full block      number=11 hash=4c92d8…336e91 td=382991890 age=1d57m48s
INFO [05-02|22:38:41.047] Loaded most recent local fast block      number=11 hash=4c92d8…336e91 td=382991890 age=1d57m48s
INFO [05-02|22:38:41.048] Loaded local transaction journal         transactions=1 dropped=1
INFO [05-02|22:38:41.048] Regenerated local transaction journal    transactions=0 accounts=0
WARN [05-02|22:38:41.048] Blockchain not empty, fast sync disabled 
INFO [05-02|22:38:41.049] Starting P2P networking 
INFO [05-02|22:38:43.272] Mapped network port                      proto=udp extport=30303 intport=30303 interface="UPNP IGDv1-IP1"
INFO [05-02|22:38:43.383] UDP listener up                          self=enode://21d2a8209dc9aeadd15d94c2df30128dd7bd4b772f34e61e8f76afb893a2f7735a77c9061b64076ca61b5635b5d434fa32600af0e56f833fd7e582bff94e679d@222.201.145.179:30303
INFO [05-02|22:38:43.383] RLPx listener up                         self=enode://21d2a8209dc9aeadd15d94c2df30128dd7bd4b772f34e61e8f76afb893a2f7735a77c9061b64076ca61b5635b5d434fa32600af0e56f833fd7e582bff94e679d@222.201.145.179:30303
INFO [05-02|22:38:43.386] IPC endpoint opened                      url=/home/hadoop/blockchain/test/geth.ipc
INFO [05-02|22:38:43.418] Mapped network port                      proto=tcp extport=30303 intport=30303 interface="UPNP IGDv1-IP1"
Welcome to the Geth JavaScript console!

instance: Geth/v1.8.17-stable-8bbe7207/linux-amd64/go1.10
INFO [05-02|22:38:43.485] Etherbase automatically configured       address=0x6393Bb737b95465cCD9E4597dF0647CdcD09775f
coinbase: 0x6393bb737b95465ccd9e4597df0647cdcd09775f
at block: 11 (Wed, 01 May 2019 21:40:53 CST)
 datadir: /home/hadoop/blockchain/test
 modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> 

4. init

init命令是用于初始化一个区块链的,通常将genesis.json文件中的初始区块信息加载到区块链中:

hadoop@tomcat:~/blockchain$ mkdir test2
hadoop@tomcat:~/blockchain$ geth --datadir test2  init genesis.json 
INFO [05-02|22:45:45.306] Maximum peer count                       ETH=25 LES=0 total=25
INFO [05-02|22:45:45.306] Allocated cache and file handles         database=/home/hadoop/blockchain/test2/geth/chaindata cache=16 handles=16
INFO [05-02|22:45:45.389] Writing custom genesis block 
INFO [05-02|22:45:45.389] Persisted trie from memory database      nodes=0 size=0.00B time=5.821µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [05-02|22:45:45.390] Successfully wrote genesis state         database=chaindata                                    hash=b123b8…4077eb
INFO [05-02|22:45:45.390] Allocated cache and file handles         database=/home/hadoop/blockchain/test2/geth/lightchaindata cache=16 handles=16
INFO [05-02|22:45:45.394] Writing custom genesis block 
INFO [05-02|22:45:45.394] Persisted trie from memory database      nodes=0 size=0.00B time=3.963µs gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [05-02|22:45:45.395] Successfully wrote genesis state         database=lightchaindata                                    hash=b123b8…4077eb

5. js

js命令用于加载一个js文件:

hadoop@tomcat:~/blockchain$ geth js t.js
INFO [05-02|22:51:21.166] Maximum peer count                       ETH=25 LES=0 total=25
INFO [05-02|22:51:21.167] Starting peer-to-peer node               instance=Geth/v1.8.17-stable-8bbe7207/linux-amd64/go1.10
INFO [05-02|22:51:21.167] Allocated cache and file handles         database=/home/hadoop/.ethereum/geth/chaindata cache=768 handles=512
INFO [05-02|22:51:21.180] Initialised chain configuration          config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}"
INFO [05-02|22:51:21.180] Disk storage enabled for ethash caches   dir=/home/hadoop/.ethereum/geth/ethash count=3
INFO [05-02|22:51:21.180] Disk storage enabled for ethash DAGs     dir=/home/hadoop/.ethash               count=2
INFO [05-02|22:51:21.180] Initialising Ethereum protocol           versions="[63 62]" network=1
INFO [05-02|22:51:21.181] Loaded most recent local header          number=192 hash=723899…123390 td=3453055867795 age=3y9mo3w
INFO [05-02|22:51:21.181] Loaded most recent local full block      number=0   hash=d4e567…cb8fa3 td=17179869184   age=50y2w4d
INFO [05-02|22:51:21.182] Loaded most recent local fast block      number=2   hash=b495a1…4698c9 td=51514445824   age=3y9mo3w
INFO [05-02|22:51:21.182] Loaded local transaction journal         transactions=0 dropped=0
INFO [05-02|22:51:21.182] Regenerated local transaction journal    transactions=0 accounts=0
INFO [05-02|22:51:21.183] Starting P2P networking 
INFO [05-02|22:51:23.318] Mapped network port                      proto=udp extport=30303 intport=30303 interface="UPNP IGDv2-IP1"
INFO [05-02|22:51:23.319] UDP listener up                          self=enode://d592b7cef587ea2350632e2811807a59026e31fc0b8dda1d7ab6ebbd7fa7a7f838848f456be0ad0b69f2cabc2f08b8e0747f64c723b547bac459d7c06b7189ef@222.201.145.179:30303
INFO [05-02|22:51:23.319] RLPx listener up                         self=enode://d592b7cef587ea2350632e2811807a59026e31fc0b8dda1d7ab6ebbd7fa7a7f838848f456be0ad0b69f2cabc2f08b8e0747f64c723b547bac459d7c06b7189ef@222.201.145.179:30303
INFO [05-02|22:51:23.320] IPC endpoint opened                      url=/home/hadoop/.ethereum/geth.ipc
INFO [05-02|22:51:23.346] Mapped network port                      proto=tcp extport=30303 intport=30303 interface="UPNP IGDv2-IP1"
INFO [05-02|22:51:23.423] Etherbase automatically configured       address=0x39270dCA851f877e25DE0B3dD2bC362a56c93d14
INFO [05-02|22:51:23.424] IPC endpoint closed                      endpoint=/home/hadoop/.ethereum/geth.ipc
INFO [05-02|22:51:23.424] Blockchain manager stopped 
INFO [05-02|22:51:23.424] Stopping Ethereum protocol 
INFO [05-02|22:51:23.424] Ethereum protocol stopped 
INFO [05-02|22:51:23.424] Transaction pool stopped 
INFO [05-02|22:51:23.424] Database closed                          database=/home/hadoop/.ethereum/geth/chaindata

options简介

options的内容相对更多:

ETHEREUM OPTIONS:
  --config value                      TOML configuration file
  --datadir "/home/hadoop/.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
  
DEVELOPER CHAIN OPTIONS:
  --dev               Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled
  --dev.period value  Block period to use in developer mode (0 = mine only if transaction pending) (default: 0)
  
ETHASH OPTIONS:
  --ethash.cachedir                       Directory to store the ethash verification caches (default = inside the datadir)
  --ethash.cachesinmem value              Number of recent ethash caches to keep in memory (16MB each) (default: 2)
  --ethash.cachesondisk value             Number of recent ethash caches to keep on disk (16MB each) (default: 3)
  --ethash.dagdir "/home/hadoop/.ethash"  Directory to store the ethash mining DAGs (default = inside home folder)
  --ethash.dagsinmem value                Number of recent ethash mining DAGs to keep in memory (1+GB each) (default: 1)
  --ethash.dagsondisk value               Number of recent ethash mining DAGs to keep on disk (1+GB each) (default: 2)
  
TRANSACTION POOL OPTIONS:
  --txpool.locals value        Comma separated accounts to treat as locals (no flush, priority inclusion)
  --txpool.nolocals            Disables price exemptions for locally submitted transactions
  --txpool.journal value       Disk journal for local transaction to survive node restarts (default: "transactions.rlp")
  --txpool.rejournal value     Time interval to regenerate the local transaction journal (default: 1h0m0s)
  --txpool.pricelimit value    Minimum gas price limit to enforce for acceptance into the pool (default: 1)
  --txpool.pricebump value     Price bump percentage to replace an already existing transaction (default: 10)
  --txpool.accountslots value  Minimum number of executable transaction slots guaranteed per account (default: 16)
  --txpool.globalslots value   Maximum number of executable transaction slots for all accounts (default: 4096)
  --txpool.accountqueue value  Maximum number of non-executable transaction slots permitted per account (default: 64)
  --txpool.globalqueue value   Maximum number of non-executable transaction slots for all accounts (default: 1024)
  --txpool.lifetime value      Maximum amount of time non-executable transaction are queued (default: 3h0m0s)
  
PERFORMANCE TUNING OPTIONS:
  --cache value            Megabytes of memory allocated to internal caching (default: 1024)
  --cache.database value   Percentage of cache memory allowance to use for database io (default: 75)
  --cache.gc value         Percentage of cache memory allowance to use for trie pruning (default: 25)
  --trie-cache-gens value  Number of trie node generations to keep in memory (default: 120)
  
ACCOUNT OPTIONS:
  --unlock value    Comma separated list of accounts to unlock
  --password value  Password file to use for non-interactive password input
  
API AND CONSOLE OPTIONS:
  --rpc                  Enable the HTTP-RPC server
  --rpcaddr value        HTTP-RPC server listening interface (default: "localhost")
  --rpcport value        HTTP-RPC server listening port (default: 8545)
  --rpcapi value         API's offered over the HTTP-RPC interface
  --ws                   Enable the WS-RPC server
  --wsaddr value         WS-RPC server listening interface (default: "localhost")
  --wsport value         WS-RPC server listening port (default: 8546)
  --wsapi value          API's offered over the WS-RPC interface
  --wsorigins value      Origins from which to accept websockets requests
  --ipcdisable           Disable the IPC-RPC server
  --ipcpath              Filename for IPC socket/pipe within the datadir (explicit paths escape it)
  --rpccorsdomain value  Comma separated list of domains from which to accept cross origin requests (browser enforced)
  --rpcvhosts value      Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. (default: "localhost")
  --jspath loadScript    JavaScript root path for loadScript (default: ".")
  --exec value           Execute JavaScript statement
  --preload value        Comma separated list of JavaScript files to preload into the console
  
NETWORKING OPTIONS:
  --bootnodes value     Comma separated enode URLs for P2P discovery bootstrap (set v4+v5 instead for light servers)
  --bootnodesv4 value   Comma separated enode URLs for P2P v4 discovery bootstrap (light server, full nodes)
  --bootnodesv5 value   Comma separated enode URLs for P2P v5 discovery bootstrap (light server, light nodes)
  --port value          Network listening port (default: 30303)
  --maxpeers value      Maximum number of network peers (network disabled if set to 0) (default: 25)
  --maxpendpeers value  Maximum number of pending connection attempts (defaults used if set to 0) (default: 0)
  --nat value           NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: "any")
  --nodiscover          Disables the peer discovery mechanism (manual peer addition)
  --v5disc              Enables the experimental RLPx V5 (Topic Discovery) mechanism
  --netrestrict value   Restricts network communication to the given IP networks (CIDR masks)
  --nodekey value       P2P node key file
  --nodekeyhex value    P2P node key as hex (for testing)
  
MINER OPTIONS:
  --mine                         Enable mining
  --miner.threads value          Number of CPU threads to use for mining (default: 0)
  --miner.notify value           Comma separated HTTP URL list to notify of new work packages
  --miner.gasprice "1000000000"  Minimum gas price for mining a transaction
  --miner.gastarget value        Target gas floor for mined blocks (default: 8000000)
  --miner.gaslimit value         Target gas ceiling for mined blocks (default: 8000000)
  --miner.etherbase value        Public address for block mining rewards (default = first account) (default: "0")
  --miner.extradata value        Block extra data set by the miner (default = client version)
  --miner.recommit value         Time interval to recreate the block being mined (default: 3s)
  --miner.noverify               Disable remote sealing verification
  
GAS PRICE ORACLE OPTIONS:
  --gpoblocks value      Number of recent blocks to check for gas prices (default: 20)
  --gpopercentile value  Suggested gas price is the given percentile of a set of recent transaction gas prices (default: 60)
  
VIRTUAL MACHINE OPTIONS:
  --vmdebug         Record information useful for VM and contract debugging
  --vm.evm value    External EVM configuration (default = built-in interpreter)
  --vm.ewasm value  External ewasm configuration (default = built-in interpreter)
  
LOGGING AND DEBUGGING OPTIONS:
  --fakepow                 Disables proof-of-work verification
  --nocompaction            Disables db compaction after import
  --verbosity value         Logging verbosity: 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=detail (default: 3)
  --vmodule value           Per-module verbosity: comma-separated list of <pattern>=<level> (e.g. eth/*=5,p2p=4)
  --backtrace value         Request a stack trace at a specific logging statement (e.g. "block.go:271")
  --debug                   Prepends log messages with call-site location (file and line number)
  --pprof                   Enable the pprof HTTP server
  --pprofaddr value         pprof HTTP server listening interface (default: "127.0.0.1")
  --pprofport value         pprof HTTP server listening port (default: 6060)
  --memprofilerate value    Turn on memory profiling with the given rate (default: 524288)
  --blockprofilerate value  Turn on block profiling with the given rate (default: 0)
  --cpuprofile value        Write CPU profile to the given file
  --trace value             Write execution trace to the given file
  
METRICS AND STATS OPTIONS:
  --metrics                          Enable metrics collection and reporting
  --metrics.influxdb                 Enable metrics export/push to an external InfluxDB database
  --metrics.influxdb.endpoint value  InfluxDB API endpoint to report metrics to (default: "http://localhost:8086")
  --metrics.influxdb.database value  InfluxDB database name to push reported metrics to (default: "geth")
  --metrics.influxdb.username value  Username to authorize access to the database (default: "test")
  --metrics.influxdb.password value  Password to authorize access to the database (default: "test")
  --metrics.influxdb.host.tag host   InfluxDB host tag attached to all measurements (default: "localhost")
  
WHISPER (EXPERIMENTAL) OPTIONS:
  --shh                       Enable Whisper
  --shh.maxmessagesize value  Max message size accepted (default: 1048576)
  --shh.pow value             Minimum POW accepted (default: 0.2)
  --shh.restrict-light        Restrict connection between two whisper light clients
  
DEPRECATED OPTIONS:
  --minerthreads value     Number of CPU threads to use for mining (deprecated, use --miner.threads) (default: 0)
  --targetgaslimit value   Target gas floor for mined blocks (deprecated, use --miner.gastarget) (default: 8000000)
  --gasprice "1000000000"  Minimum gas price for mining a transaction (deprecated, use --miner.gasprice)
  --etherbase value        Public address for block mining rewards (default = first account, deprecated, use --miner.etherbase) (default: "0")
  --extradata value        Block extra data set by the miner (default = client version, deprecated, use --miner.extradata)
  
MISC OPTIONS:
  --help, -h  show help

options的内容较多,此处也是简略介绍部分用得到的内容。

1. --datadir

该命令用于指定区块链数据的存储文件夹,在区块链启动过程中需要自定义数据文件夹的情况下都会用到该选项,在上一篇中已经经过实践展示。

2. --testnet和--rinkeby

这两个选项用于选择网络类型,在创建私链的情况下不会使用到,是以太坊的两个测试公链。

3. --syncmode

用于指示同步模式,有"fast"/"full"/"light"三种选项,分别表示全节点模式,快速同步模式和轻节点模式,全节点会同步区块链中的所有数据;快速同步模式采取先同步完成再校验状态的方法;轻节点只同步区块头信息,不拥有完整的交易信息和状态信息,但是可以通过区块头中的交易树和状态树根节点hash值来验证交易信息和状态信息的有效性。

4. --unlock和--password

这两个参数用于解锁某个账户。

5. --rpc、--rpcaddr、--rpcport和--rpcapi

第一个参数用于打开rpc支持;其后三个参数分别指定rpc服务地址、rpc服务端口和rpc支持的接口。

6. --bootnodes

该参数可用于与其他节点进行连接并且信息交互。

7. --port

该参数指定P2P服务端口。

8. --mine

该参数用于启动挖矿进程。

联系与交流

欢迎小伙伴与我讨论哦~

邮箱:zsunny@yeah.net

本文欢迎转载,请注明本文地址:https://www.jianshu.com/p/d07ebc80506b

上一篇下一篇

猜你喜欢

热点阅读