在成功构建项目后,nodeos二进制文件应该在build/programs/nodeos文件夹中。可以使用programs/nodeos/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一起运行。
下面的图表描述了我们刚刚创建的单个主机测试链(网)。cleos用于管理钱包、管理帐号、调用区块链上的操作。默认情况下,keosd由cleos启动,以执行钱包管理。

更多步骤
更高级的用户可能需要修改配置。nodeos使用自定义配置文件夹。该文件夹的位置由你的系统决定。
- Mac OS:
~/Library/Application\ Support/eosio/nodeos/config - Linux:
~/.local/share/eosio/nodeos/config
使用默认genesis.json文件生成此文件夹的种子。可以使用--config-dir命令行参数向nodeos指定配置文件夹。如果使用此选项,则需要手动将genesis.json文件复制到配置文件夹中。
为了完成有意义的工作,nodeos需要一个正确配置的config.ini文件。启动时,nodeos文件夹查找config.ini。如果未找到,则创建默认的配置文件config.ini。如果你还没有准备好可以使用的配置文件,请运行nodeos,然后用Ctrl C立即关闭它。默认配置(config.ini)将在配置文件夹中创建。编辑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在自定义数据文件夹中存储运行时数据(例如,共享内存和日志内容)。该文件夹的位置由你的系统决定。
- Mac OS:
~/Library/Application\ Support/eosio/nodeos/data - Linux:
~/.local/share/eosio/nodeos/data
可以使用--data-dir命令行参数通过nodeos指定数据文件夹。
分享一个EOS智能合约与DApp开发入门教程,欢迎大家来学习互动:
本教程帮助你快速入门EOS区块链去中心化应用的开发,内容涵盖EOS工具链、账户与钱包、发行代币、智能合约开发与部署、使用代码与智能合约交互等核心知识点,最后综合运用React和EOS的各知识点完成一个便签DApp的开发。
原文转自:http://blog.hubwiz.com/2018/07/30/EOS-nodeos-LocalSingleNode/
本文介绍了如何安装和设置EOS的nodeos,以创建一个本地单节点测试链。通过运行特定命令启动节点,查看日志确认区块链成功运行。此外,文章提到了配置文件和数据文件夹的路径,以及如何编辑配置文件以启用块生产。同时,分享了一个EOS智能合约与DApp开发的入门教程链接。
2093

被折叠的 条评论
为什么被折叠?



