EOS开发 第三篇 生成EOS并运行节点

in #eos6 years ago (edited)

 作者: Harvey Meng   微信: menhigkong   日期: 2018年3月19日  

获取代码

要下载所有的代码,请下载EOS源代码和一个或两个子模块的递归。 最简单的方法是做一个递归克隆:

git clone https://github.com/eosio/eos --recursive

如果没有使用 --recursive 标志来克隆代码库,则可以在代码库内运行以下命令来检索子模块: 

git submodule update --init --recursive

从源代码生成 

cd ~

git clone https://github.com/eosio/eos --recursive
mkdir -p ~/eos/build && cd ~/eos/build
cmake -DBINARYEN_BIN=~/binaryen/bin -DWASM_ROOT=~/wasm-compiler/llvm -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib ..
make -j$( nproc )

外部生成也支持。 要在编译器中覆盖clang的默认选项,请将这些标志添加到CMake命令中:

 -DCMAKE_CXX_COMPILER=/path/to/c++ -DCMAKE_C_COMPILER=/path/to/cc 

对于调试版本,请添加-DCMAKE_BUILD_TYPE = Debug。 其他常见的生成类型包括ReleaseRelWithDebInfo

为了在生成之后运行测试套件,请运行tests文件夹中的可执行文件chain_test

EOS自带了许多程序,你可以在~/eos/build/programs中找到。 如下:

  • eosiod - 服务器端区块链节点组件
  • eosioc - 命令行界面与区块链交互
  • eosiowd - EOS钱包
  • eosio-launcher - 应用程序的节点网络组成和部署;  更多内容在 eosio-launcher 

创建并启动单节点测试网

在成功构建项目之后,eosiod二进制文件应该存在于 build/programs/eosiod 目录中。 运行eosiod - 它可能会退出并显示错误,但如果没有,请立即用Ctrl-C关闭它。 如果它出现错误退出,请注意,eosiod创建了一个名为data-dir的目录,其中包含默认配置(config.ini)和其他一些内部信息。 这个默认的数据存储路径可以通过 --data-dir /path/to/data 被复写到eosiod。 这些指令将继续使用默认目录。

编辑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 = inita
producer-name = initb
producer-name = initc
producer-name = initd
producer-name = inite
producer-name = initf
producer-name = initg
producer-name = inith
producer-name = initi
producer-name = initj
producer-name = initk
producer-name = initl
producer-name = initm
producer-name = initn
producer-name = inito
producer-name = initp
producer-name = initq
producer-name = initr
producer-name = inits
producer-name = initt
producer-name = initu
# 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

现在应该可以运行eosiod并看到它开始生成块。 您可以通过将--config-dir参数传递给eosiod来指定自定义config.ini的位置。

运行eosiod时,您应该看到如下所示的日志消息。 这意味着这些模块已经成功生产。 

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

...

下一步

更多文档可在维基中找到。 维基页面包含所有程序和工具以及数据库模式和API的详细参考文档。 维基还包含一章描述智能合约开发的内容。 

Sort:  

amazing so cute love u

Coin Marketplace

STEEM 0.19
TRX 0.14
JST 0.030
BTC 60268.51
ETH 3201.96
USDT 1.00
SBD 2.43