人人都在说EOS,但你知道怎么启动EOS吗
启动单节点网络
EOS编译完成之后,生成的执行文件nodeos
在build/programs/nodes
目录下,运行单阶段区块链很简单,只需要执行
./nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::chain_api_plugin --plugin eosio::account_history_api_plugin
参数解释:
- -e [ --enable-stale-production ] Enable block production, even if the chain is stale. 使能出块
- -p [ --producer-name ] arg ID of producer controlled by this node (e.g. inita; may specify multiple times) 块产生者的名称
- --plugin arg Plugin(s) to enable, may be specified multiple times 使能插件
执行命令之后出现类似下面的输出:
eosio generated block 0290ec8e... #234 @ 2018-04-26T14:35:27.000 with 0 trxs, lib: 233
eosio generated block 4fa6a13b... #235 @ 2018-04-26T14:35:27.500 with 0 trxs, lib: 234
eosio generated block 3c85b588... #236 @ 2018-04-26T14:35:28.000 with 0 trxs, lib: 235
说明nodeos已经运行起来,只有一个生产者eosio,并且已经正常出块了。
在来回顾一下这种图 注意,在单节点网络中没有单独的keosd钱包,使用了nodeos命令行参数中所示的钱包插件,由cleos管理钱包,管理账户,和调用区块链上的动作。
高级设置
如果用户想要修改配置,nodeos提供了相应的配置文件,不同系统下配置文件的路径:
- Mac OS: ~/Library/Application Support/eosio/nodeos/config
- Linux: ~/.local/share/eosio/nodeos/config
该目录下有两个配置文件,分别是genesis.json
和config.ini
,这两个文件在编译安装后会默认生成。
命令行中的参数我们也可以在config.ini
这个文件中指定,比如
# Load the testnet genesis state, which creates some initial block producers with the default key
genesis-json = /path/to/eos/source/genesis.json
# Enable production on a stale chain, since a single-node test chain is pretty much always stale
enable-stale-production = true
# Enable block production with the testnet producers
producer-name = eosio
# Load the block producer plugin, so you can produce blocks
plugin = eosio::producer_plugin
# Wallet plugin
plugin = eosio::wallet_api_plugin
# As well as API and HTTP plugins
plugin = eosio::chain_api_plugin
plugin = eosio::http_plugin
# This will be used by the validation step below, to view account history
plugin = eosio::account_history_api_plugin
这样配好之后,就可以直接在build/programs/nodes
下执行./nodeos
,效果跟之前加参数时一样。
nodeos 的运行数据文件夹(log和共享存储等数据)位于以下文件夹:
-
Mac OS: ~/Library/Application Support/eosio/nodeos/data
-
Linux: ~/.local/share/eosio/nodeos/data
但也可以使用 nodeos 的 --data-dir 命令重新指定数据文件夹。
- 查看eos信息 eos服务启动之后,可通过命令查看相关信息:
cleos -H 127.0.0.1 -p 8888 get info
{
"server_version": "b8351132",
"head_block_num": 9023,
"last_irreversible_block_num": 9022,
"head_block_id": "0000233f47be625319f593540ae045dcb77404ac118a6751a6d27405d7e08fc3",
"head_block_time": "2018-05-09T14:22:09",
"head_block_producer": "eosio"
}
「力场 lichang.io 」公链挖矿第一社区!
福利:
引力区2019重磅产品「力场」开放注册了,实名注册就送7.5万LC,还有更多赚取LC玩法,快来和我一起挖矿。http://lichang.io/#/home?invite=qDe5
参考
https://github.com/EOSIO/eos/wiki/Local-Environment#4-creating-and-launching-a-single-node-testnet
系列文章
【系列】EOS开发1 开发环境搭建
【系列】EOS开发0 资料汇总篇--持续更新