概念:
geth是go-ethereum中最主要的一个命令行工具,也是各种网络的接入点,支持全节点和轻节点模式,其它程序也可以通过暴露的JSON RPC接口调用访问以太访网络。
主要引用第三方的cli包实现
- 源码地址:https://gopkg.in/urfave/cli.v1
- 概念:一个基于go开发的用于在go里面构建命令行的应用程序
geth启动流程分析
- 通过init做一个geth整体初始化
// geth整体初始化
func init() {
// 命令/行为,如果用户没有输入其它子命令,就调用这个字段指向的函数
app.Action = geth
app.HideVersion = true // we have a command to print the version
app.Copyright = "Copyright 2013-2017 The go-ethereum Authors"
// 所有支持的子命令
app.Commands = []cli.Command{
// See chaincmd.go:
initCommand,
importCommand,
exportCommand,
copydbCommand,
removedbCommand,
dumpCommand,
monitorCommand,
// 账号管理
accountCommand,
walletCommand,
consoleCommand,
attachCommand,
javascriptCommand,
makecacheCommand,
makedagCommand,
versionCommand,
bugCommand,
licenseCommand,
// Se