成功构建项目后,nodeos
二进制文件应存在于该build/programs/nodeos
文件夹中。nodeos
可以直接从build
文件夹中运行programs/nodeos/nodeos
,也可以cd programs/nodeos
更改到文件夹并nodeos
从那里运行命令。在这里,我们在programs/nodeos
文件夹中运行命令。
您可以使用以下单个命令启动自己的单节点区块链:
cd build/programs/nodeos
./nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin
运行时,nodeos
您应该获得类似于下面的日志消息。这意味着块已成功生成。
1575001ms thread-0 chain_controller.cpp:235 _push_block ] initm #1 @2017-09-04T04:26:15 | 0 trx, 0 pending, exectime_ms=0
1575001ms thread-0 producer_plugin.cpp:207 block_production_loo ] initm generated block #1 @ 2017-09-04T04:26:15 with 0 trxs 0 pending
1578001ms thread-0 chain_controller.cpp:235 _push_block ] initc #2 @2017-09-04T04:26:18 | 0 trx, 0 pending, exectime_ms=0
1578001ms thread-0 producer_plugin.cpp:207 block_production_loo ] initc generated block #2 @ 2017-09-04T04:26:18 with 0 trxs 0 pending
...
eosio generated block 046b9984... #101527 @ 2018-04-01T14:24:58.000 with 0 trxs
eosio generated block 5e527ee2... #101528 @ 2018-04-01T14:24:58.500 with 0 trxs
...
此时,nodeos
正在与一个生产者一起运行eosio
。
下图描绘了我们刚刚创建的单个主机testnet。 cleos
用于管理钱包,管理帐户以及调用区块链上的操作。默认情况下,keosd
启动cleos
时执行钱包管理。
高级步骤
更高级的用户可能需要修改配置。 nodeos
使用自定义配置文件夹。此文件夹的位置由您的系统决定。
- 苹果系统:
~/Library/Application\ Support/eosio/nodeos/config
- Linux的:
~/.local/share/eosio/nodeos/config
构建使用默认genesis.json
文件为此文件夹设置种子。可以使用--config-dir
命令行参数to 指定配置文件夹nodeos
。如果使用此选项,则需要手动将genesis.json
文件复制到config文件夹。
nodeos
将需要一个正确配置的config.ini
文件,以便做有意义的工作。在启动时,nodeos
在config文件夹中查找config.ini
。如果找不到,config.ini
则创建默认文件。如果您还没有config.ini
准备好使用的文件,请运行nodeos
,然后立即使用<kbd> Ctrl-C </ kbd>将其关闭。config.ini
将在config文件夹中创建默认配置()。编辑config.ini
文件,将以下设置添加/更新为已有的默认值:
# 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
# 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 history
plugin = eosio::history_api_plugin
现在它应该可以运行nodeos
并看到它开始生成块。
./programs/nodeos/nodeos
nodeos
将运行时数据(例如,共享内存和日志内容)存储在自定义数据文件夹中。此文件夹的位置由您的系统决定。
- 苹果系统:
~/Library/Application\ Support/eosio/nodeos/data
- Linux的:
~/.local/share/eosio/nodeos/data
可以使用--data-dir
命令行参数指定数据文件夹nodeos
。