进入geth交互平台的命令大全解释

这里有很多进入geth平台的命令参数来确保你的链是私链

  • nodiscover:不被其他节点发现,但是如果有相同创世块和networkid的节点可以连接进私链
--nodiscover
Use this to make sure that your node is not discoverable by people who do not manually add you. Otherwise, there is a chance that your node may be inadvertently added to a stranger's node if they have the same genesis file and network id.
  • maxpeers 私链最大的界点数量
--maxpeers 0
Use maxpeers 0 if you do not want anyone else connecting to your test chain. Alternatively, you can adjust this number if you know exactly how many peers you want connecting to your private chain.
  • rpc 一般是默认,用于节点提供rpc接口
--rpc
This will enable RPC interface on your node. This is generally enabled by default in Geth.
  • rpcapi 通过rpc可以连接的API接口 ,一般默认有”db,eth,net,web3”
--rpcapi "db,eth,net,web3"
This dictates what APIs that are allowed to be accessed over RPC. By default, Geth enables the web3 interface over RPC.
IMPORTANT: Please note that offering an API over the RPC/IPC interface will give everyone access to the API who can access this interface (e.g. DApp's). Be careful which API's you enable. By default geth enables all API's over the ipc interface and only the db,eth,net and web3 API's over the RPC interface.
  • rpcport “8080” 任何本地网络打开的接口
--rpcport "8080"
Change 8000 to any port that is open on your network. The default for geth is 8080 and althzero is 8545.
  • rpccorsdomain 用来连接网址
--rpccorsdomain "*"
This dictates what URLs can connect to your node in order to perform RPC client tasks. Be very careful with this and when possible, put a specific URL rather than the wildcard (*) which allows any URL to connect to your RPC instance. Since this is a private chain that will not hold real Ether, I usually put a wildcard so I can use sites such as Browser Solidity or DApps like Notareth. When you build DApps outside of Mist or Alethzero, you will need to connect your website to an Ethereum node.
  • datadir 用来存放私链数据的目录
--datadir "/home/HudsonChain1"
This is the data directory that your private chain data will be stored in. Choose a location that is separate from the public Ethereum chain folder.
  • 网络监听端口,用来其他节点的连接
--port "30303"
This is the "network listening port", which you will use to connect with other peers manually.
  • nat “any” 一般不做处理
--nat "any"
I use the NAT any setting, but this will be dependent on your network configuration.
  • identity 给节点命名
--identity "HudsonMainNode" This will set up an identity for your node so it can be identified more easily in a list of peers. Here is an example of how these identities show up on the network.
Notice the lines with "HudsonMainNode" and "Hudson2ndNode"
Putting it All Together

每次运行私链都需要geth 命令

You will need to start your geth instance with your custom chain command every time you want to access your custom chain. If you just type “geth” in your console, it will not remember all of the flags you have set.
After you have created your custom genesis block JSON file and created a directory for your chain to go into, type the following command into your console that has access to geth:

进入geth

geth --identity "MyNodeName" --genesis CustomGenesis.json --rpc --rpcport "8000" --rpccorsdomain "*" --datadir "C:\chains\VPSChain" --port "30303" --nodiscover --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcapi "db,eth,net,web3" --autodag --networkid 1900 --nat "any" console

可以用shell脚本自动运行

Note: Please change the flags to match your custom settings.
You will need to start your geth instance with your custom chain command every time you want to access your custom chain. If you just type "geth" in your console, it will not remember all of the flags you have set. Different operating systems have ways to make this easier. Most allow you to make a shortcut file that will automatically open a console window and run commands that you specify. On Windows systems, look up how to create a .bat or .cmd file that runs the commands you require. On Linux/Unix/Mac systems, look up .sh files.

你可能感兴趣的:(以太坊)