兄弟连区块链教程eth源码分析CMD深入分析(二),cmd包下的geth子包主函数启动的各个子命令解析### cmd包下的geth子包主函数启动的各个子命令解析#### /geth* __init__
Function: Import the JSON of the Genesis block with the specified JSON as the Genesis block
Args:<genesispath>
Demo:init/home/yujian/eth-go/genesis.json
Notice:ethereum default creation path for the. Ethereum of the home directory, if the directory has been written to the creation of the fast, will fail to execute
Success_result_demo:
WARN [01-16|10:25:12] No etherbase set and no accounts found as default
INFO [01-16|10:25:12] Allocated cache and file handles Database=/home/yujian/.ethereum/geth/chaindata cache=16 handles= 16
INFO [01-16|10:25:12] Writing Custom Genesis block
INFO [01-16|10:25:12] successfully wrote Genesis State Database=chaindata hash=bf2891...ad1419
INFO [01-16|10:25:12] Allocated cache and file handles Database=/home/yujian/.ethereum/geth/lightchaindata cache=16 Handles=16
INFO [01-16|10:25:12] Writing Custom Genesis block
INFO [01-16|10:25:12] successfully wrote Genesis State Database=lightchaindata hash=bf2891...ad1419
* __import__
Function: Import chunk data into the currently running chain
args:<filename> (<filename 2> ... <filename n>)
Demo:import/home /yujian/eth-block.txt
Notice: If the imported file is wrong, it will fail, and if there are multiple file errors, the program will continue to ignore the error.
Success_result_demo:
WARN [01-16|11:00:32] No etherbase set and no accounts found as default
INFO [01-16|11:00: Allocated cache and file handles Database=/home/yujian/.ethereum/geth/chaindata cache=128 handles=1024
Import Done in 306.866μs.
INFO [01-16|11:00:32] Disk storage enabled for Ethash caches Dir=/home/yujian/.ethereum/geth/ethash count=3
Compactions
INFO [01-16|11:00:32] Disk storage enabled for Ethash DAGs dir=/home/yujian/.ethash count=2
Level | Tables | Size (MB) | Time (sec) | Read (MB) | Write (MB)
-------+------------+---------------+---------------+---------------+---------------
INFO [01-16|11:00:32] Loaded most recent local header number=0 hash=bf2891...ad1419 td=33554432
0 | 3 | 0.00094 | 0.00000 | 0.00000 | 0.00000
INFO [01-16|11:00:32] Loaded most recent local full block number=0 hash=bf2891...ad1419 td=33554432
Trie Cache misses:0
INFO [01-16|11:00:32] Loaded most recent local fast block number=0 hash=bf2891...ad1419 td=33554432
Trie Cache unloads:0
INFO [01-16|11:00:32] Importing blockchain file=/home/yujian/eth-block.txt
Object memory:34.677 MB Current, 34.670 MB peak
System memory:74.100 MB Current, 73.850 MB peak
ALLOCATIONS:0.015 million
GC pause:10.454997ms
Compacting entire database ...
INFO [01-16|11:00:33] Database closed Database=/home/yujian/.ethereum/geth/chaindata
Compaction done in 64.422235ms.
Compactions
Level | Tables | Size (MB) | Time (sec) | Read (MB) | Write (MB)
-------+------------+---------------+---------------+---------------+---------------
0 | 0 | 0.00000 | 0.00451 | 0.00000 | 0.00021
1 | 1 | 0.00053 | 0.00435 | 0.00114 | 0.00053
* __export__
Function: Export chunk data to the specified file
Args:<filename> [<blocknumfirst> <blocknumlast>]
Demo:export/home/yujian/eth-block.txt
Notice
Success_result_demo:
WARN [01-16|10:51:36] No etherbase set and no accounts found as default
INFO [01-16|10:51:36] Allocated cache and file handles Database=/home/yujian/.ethereum/geth/chaindata cache=128 handles =1024
INFO [01-16|10:51:36] Disk storage enabled for Ethash caches Dir=/home/yujian/.ethereum/geth/ethash count=3
INFO [01-16|10:51:36] Disk storage enabled for Ethash DAGs dir=/home/yujian/.ethash count=2
Export done in 628.951μsinfo [01-16|10:51:36] Loaded most recent local header number=0 hash=bf2891...ad1419 td=33554432
INFO [01-16|10:51:36] Loaded most recent local full block number=0 hash=bf2891...ad1419 td=33554432
INFO [01-16|10:51:36] Loaded most recent local fast block number=0 hash=bf2891...ad1419 td=33554432
INFO [01-16|10:51:36] exporting blockchain file=/home/yujian/eth-block.txt
INFO [01-16|10:51:36] exporting batch of blocks Count=1
INFO [01-16|10:51:36] exported blockchain file=/home/yujian/eth-block.txt
* __copydb__
Function: Creates a local chain from the existing chain Data folder
Args:<sourcechaindatadir>
Demo:copydb/home/yujian/eth-block.txt
Notice
Success_result_demo:
WARN [01-16|11:35:55] No etherbase set and no accounts found as default
INFO [01-16|11:35:55] Allocated cache and file handles Database=/home/yujian/.ethereum/geth/chaindata cache=128 handles =1024
INFO [01-16|11:35:55] Disk storage enabled for Ethash caches Dir=/home/yujian/.ethereum/geth/ethash count=3
INFO [01-16|11:35:55] Disk storage enabled for Ethash DAGs dir=/home/yujian/.ethash count=2
INFO [01-16|11:35:55] Loaded most recent local header number=0 hash=bf2891...ad1419 td=33554432
INFO [01-16|11:35:55] Loaded most recent local full block number=0 hash=bf2891...ad1419 td=33554432
INFO [01-16|11:35:55] Loaded most recent local fast block number=0 hash=bf2891...ad1419 td=33554432
INFO [01-16|11:35:55] Allocated cache and file handles Database=/home/yujian/eth-go/geth/chaindata cache=128 handles= 256
INFO [01-16|11:35:55] Block synchronisation started
INFO [01-16|11:35:55] imported new state entries count=1 elapsed=33.277μs processed=1 pending=0 retry=0 duplicate=0 unexpe Cted=0
INFO [01-16|11:35:56] imported new block headers count=11 elapsed=1.276s number=11 hash=ec3374 ... 59A2BA ignored=0
Database copy done in 1.280940454s
Compacting entire database ...
INFO [01-16|11:35:56] imported new chain segment blocks=11 txs=0 mgas=0.000 elapsed=1.961ms mgasps=0.000 number=11 Hash=ec 3374 ... 59a2ba
Compaction done in 11.130389ms.
* __removedb__
Function: Removes the current chain of the database
Args: ""
Demo:removedb
Notice: Default current chain of data in the home directory under the. Ethereum Directory
Success_result_demo:
WARN [01-16|11:48:09] No etherbase set and no accounts found as default
/home/yujian/.ethereum/geth/chaindata
Remove this database? [y/n] Y
/home/yujian/.ethereum/geth/lightchaindata
INFO [01-16|11:48:19] Database successfully deleted Database=chaindata elapsed=7.832ms
Remove this database? [y/n] Y
INFO [01-16|11:48:27] Database successfully deleted Database=lightchaindata elapsed=481.229μs
* __dump__
Function: Dumps the specified block
args:[<blockhash> | <blocknum>,] ...
Demo:dump 0
Notice
Success_result_demo:
"Storage": {}
},
"af3cb5965933e7dad883693b9c3e15beb68a4873": {
"Balance": "2000000000000000000000",
"Nonce": 0,
"Root": "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"Codehash": "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"Code": "",
"Storage": {}
},
"Af4493e8521ca89d95f5267c1ab63f9f45411e1b": {
"Balance": "200000000000000000000",
"Nonce": 0,
"Root": "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"Codehash": "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"Code": "",
"Storage": {}
},
}
}
INFO [01-16|14:02:06] Database closed Database=/home/yujian/.ethereum/geth/chaindata
* __monitor__
Function: monitoring and visualization of node metrics
Args: ""
Demo:monitor
Notice: The command is not locally tuned and requires a chain to be called before the command can be invoked to see the status of the monitor.
Success_result_demo:
Todo
* __account__
Function: Manage Account
Args: "[New|list|update|import]"
Demo:account New
NOTICE: The Account import option can only be used to import a universal key file
Success_result_demo:
WARN [01-16|14:44:44] No etherbase set and no accounts found as default
Your new account was locked with a password. Please give a password. Do not forget the this password.
!! Unsupported terminal, password'll be echoed.
passphrase:123456
Repeat passphrase:123456
Address: {2A23E9223D7AF9C56F5ABD0C8226021B51C98CBC}
Process finished with exit code 0
* __wallet__
Function: Import prepayment wallet (generally not available, with account function)
Args: ""
Demo:wallet Import
NOTICE: "Wallet import" option can only be used to import presale wallets
Success_result_demo:
* __console__
Function: Turn on a private chain and open a visual JS wallet console
Args: ""
Demo:console
Notice
Success_result_demo:
INFO [01-16|15:26:13] starting Peer-to-peer node instance=geth/v1.7.3-unstable/linux-amd64/go1.9.2
INFO [01-16|15:26:13] Allocated cache and file handles Database=/home/yujian/.ethereum/geth/chaindata cache=128 handles =1024
INFO [01-16|15:26:14] initialised chain configuration config= "{chainid:1 homestead:1150000 dao:1920000 daosupport:true eip150:2463000 eip155:2675000 eip158:2675000 byzantium:4370000 Engine:ethash} "
INFO [01-16|15:26:14] Disk storage enabled for Ethash caches Dir=/home/yujian/.ethereum/geth/ethash count=3
INFO [01-16|15:26:14] Disk storage enabled for Ethash DAGs dir=/home/yujian/.ethash count=2
INFO [01-16|15:26:14] initialising Ethereum protocol versions= "[[+]] Network=1
INFO [01-16|15:26:14] Loaded most recent local header number=1127484 hash=ae7ee2 ... 52AE4C td=8985161313979839462
INFO [01-16|15:26:14] Loaded most recent local full block number=0 hash=d4e567...cb8fa3 td=17179869184
INFO [01-16|15:26:14] Loaded most recent local fast block number=1092806 hash=6e839a ... 2eb127 td=8395031237882431385
INFO [01-16|15:26:14] upgrading chain index type=bloombits percentage=80
INFO [01-16|15:26:14] Loaded local transaction journal Transactions=0 Dropped=0
INFO [01-16|15:26:14] regenerated local transaction journal Transactions=0 accounts=0
INFO [01-16|15:26:14] starting peer Networking
INFO [01-16|15:26:16] UDP listener up self=enode:// Bef014afb2b63c749d1e3917a25dc9e508cb67e6010965f11695beef50c29f40a[email protected][::]:30303
INFO [01-16|15:26:16] rlpx listener up self=enode:// Bef014afb2b63c749d1e3917a25dc9e508cb67e6010965f11695beef50c29f40a[email protected][::]:30303
INFO [01-16|15:26:16] IPC endpoint opened:/HOME/YUJIAN/.ETHEREUM/GETH.IPC
Welcome to the Geth JavaScript console!
instance:geth/v1.7.3-unstable/linux-amd64/go1.9.2
Coinbase:0x2a23e9223d7af9c56f5abd0c8226021b51c98cbc
At block:0 (Thu, Jan 1970 08:00:00 CST)
DataDir:/home/yujian/.ethereum
modules:admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
* __attach__
Function: Opens a Visual JS Wallet console (connected to a specified chain)
Args
--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
--datadir "/root/.ethereum" Data directory for the databases and KeyStore
Demo:attach--datadir= "/HOME/YUJIAN/.ETHEREUM/GETH.IPC"
Notice: You must start a local chain so that you can connect to the past
Success_result_demo:
Welcome to the Geth JavaScript console!
instance:geth/v1.7.3-unstable/linux-amd64/go1.9.2
Coinbase:0x2a23e9223d7af9c56f5abd0c8226021b51c98cbc
At block:0 (Thu, Jan 1970 08:00:00 CST)
DataDir:/home/yujian/.ethereum
modules:admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
* __js__
Function: Executes the specified JS file
args:<jsfile> [Jsfile ...]
Demo:js
Notice
Success_result_demo:
* __makecache__
Function: Generate Ethhash Validation cache (test use)
Args:<blocknum> <outputDir>
Demo:makecache 0/home/yujian/
Notice
Success_result_demo:
In the corresponding output directory, a cache file will be generated, such as cache-r23-0000000000000000
* __makedag__
Function: Generate Ethhash mining dag (test use)
args:<blocknum> <outputdir>
Demo:makedag 0/home/yujian/
Notice:
Success_result_demo:
INFO [01-16|17:50:36] generating DAG in progress epoch=0 percentage=92 elapsed= 3m2.525s
Info [01-16|17:50:38] generating DAG in progress epoch=0 percentage=93 elapsed=3m4.338s
Info [01-16| 17:50:40] Generating dag in progress epoch=0 percentage=94 elapsed=3m6.058s
INFO [01-16|17:50:41] generating dags in pro Gress epoch=0 percentage=95 elapsed=3m7.795s
INFO [01-16|17:50:43] generating DAG in progress epoch=0 percentage=96 El apsed=3m9.542s
Info [01-16|17:50:45] generating DAG in progress epoch=0 percentage=97 elapsed=3m11.380s
Info [ 01-16|17:50:47] generating DAG in progress epoch=0 percentage=98 elapsed=3m13.129s
INFO [01-16|17:50:49] Generating DAG in progress epoch=0 percentage=99 elapsed=3m15.303s
INFO [01-16|17:50:49] Generated ethash Verification Cache Epoc H=0 elapsed=3m15.306s
Process finished with exit code 0
In the corresponding output directory, a full file will be generated, such as full-r23-0000000000000000
* __version__
Function: Print version data
Args: ""
Demo:version
Notice
Success_result_demo:
Geth
Version:1.7.3-unstable
Architecture:amd64
Protocol Versions: [63 62]
Network id:1
Go version:go1.9.2
Operating System:linux
Gopath=/home/yujian/blockchain-workspace/go-project
Goroot=/usr/local/go
* __bug__
Function: Open a window and jump directly to Ethereum's GitHub repository's issue
Args: ""
Demo:bug
Notice
Success_result_demo:
After running, it will automatically open the browser and jump to Ethereum's issue edit page.
* __license__
Function: Displays Geth's license information
Args: ""
Demo:license
Notice
Success_result_demo:
Geth is free software:you can redistribute it and/or modify
It under the terms of the GNU general public License as published by
The free software Foundation, either version 3 of the License, or
(at your option) any later version.
Geth is distributed in the hope that it'll be useful,
but without any WARRANTY; Without even the implied warranty of
merchantability or FITNESS for A particular PURPOSE. See the
GNU general public License for more details.
You should has received a copy of the GNU general public License
Along with Geth. If not, see
* __dumpconfig__
Function: Display configuration information
Args: ""
Demo:dumpconfig
Notice
Success_result_demo:
[Eth]
Networkid = 1
SyncMode = "Fast"
Lightpeers = 20
Databasecache = 128
Etherbase = "0X2A23E9223D7AF9C56F5ABD0C8226021B51C98CBC"
Gasprice = 18000000000
Ethashcachedir = "Ethash"
Ethashcachesinmem = 2
Ethashcachesondisk = 3
Ethashdatasetdir = "/home/yujian/.ethash"
Ethashdatasetsinmem = 1
Ethashdatasetsondisk = 2
Enablepreimagerecording = False
[Eth.txpool]
Nolocals = False
Journal = "TRANSACTIONS.RLP"
Rejournal = 3600000000000
Pricelimit = 1
Pricebump = 10
Accountslots = 16
Globalslots = 4096
Accountqueue = 64
Globalqueue = 1024
Lifetime = 10800000000000
[Eth.gpo]
Blocks = 10
percentile = 50
[SHH]
MaxMessageSize = 1048576
Minimumacceptedpow = 2e-01
[Node]
DataDir = "/home/yujian/.ethereum"
Ipcpath = "GETH.IPC"
Httpport = 8545
httpmodules = ["Net", "Web3", "ETH", "Shh"]
Wsport = 8546
Wsmodules = ["Net", "Web3", "ETH", "Shh"]
[NODE.P2P]
Maxpeers = 25
Nodiscovery = False
DISCOVERYV5ADDR = ": 30304"
Bootstrapnodes = ["Enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29[email protected] 52.16.188.185:30303 "," Enode://3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02[email protected ]13.93.211.84:30303 "," Enode://78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a9[email protected ]191.235.84.50:30303 "," Enode://158f8aab45f6d19c6cbf4a089c2670541a8da11978a2f90dbf6a502a4a3bab80d[email protected]13.75.154.138:30303 "," enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad65[ Email protected]52.74.57.123:30303 "," enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba[ Email protected]5.1.83.226:30303 "]
BootstrapNodesV5 = ["Enode://0cc5f5ffb5d9098c8b8c62325f3797f56509bff942704687b6530992ac706e2cb[email protected] 40.118.3.223:30305 "," Enode://1c7a64d76c0334b0418c004af2f67c50e36a3be60b5e4790bdac0439d21603469[email protected] 40.118.3.223:30308 "," Enode://85c85d7143ae8bb96924f2b54f1b3e70d8c4d367af305325d30a61385a432f247[email protected] 40.118.3.223:30309 "]
Staticnodes = []
Trustednodes = []
LISTENADDR = ": 30303"
Enablemsgevents = False
[Dashboard]
Host = "localhost"
Port = 8080
Refresh = 3000000000
Blockchain tutorial ETH source code Analysis cmd in-depth analysis (II.)