Edit me

下载编译

首先到https://github.com/EOSIO/eos下载源代码,然后按照说明编译工程。

错误处理

下载错误
Unlinking /usr/local/Cellar/pkg-config/0.29.2... 4 symlinks removed
Linking /usr/local/Cellar/pkg-config/0.29.2... 4 symlinks created
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   616    0   616    0     0    493      0 --:--:--  0:00:01 --:--:--   493
  0     0    0     0    0     0      0      0 --:--:--  0:00:15 --:--:--     0curl: (6) Could not resolve host: github-production-release-asset-2e65be.s3.amazonaws.com

解决方案: 在linux的/etc/hosts上添加上以下一句,问题解决 52.216.16.16 github-production-release-asset-2e65be.s3.amazonaws.com

In file included from /Users/chandler/work/eos/contracts/libc++/upstream/src/vector.cpp:10:
In file included from /Users/chandler/work/eos/contracts/libc++/upstream/include/vector:265:
In file included from /Users/chandler/work/eos/contracts/libc++/upstream/include/iosfwd:90:
/Users/chandler/work/eos/contracts/libc++/upstream/include/wchar.h:119:15: fatal error: 'wchar.h' file not found
#include_next <wchar.h>
              ^~~~~~~~~
1 error generated.
make[2]: *** [contracts/libc++/vector.cpp.bc] Error 1

Mongo下载错误:

    Installing MongoDB 3.6.3.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:30 --:--:--     0
curl: (28) Operation timed out after 30001 milliseconds with 0 out of 0 bytes received
    Unable to download MongoDB at this time.
    Exiting now.

手动安装:

pct@Chandler:~/workspace/ABA/Codes/Eos-Env/eos$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
Executing: /tmp/apt-key-gpghome.3dTSpvOEx0/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
gpg: 密钥 58712A2291FA4AD5:公钥“MongoDB 3.6 Release Signing Key <packaging@mongodb.com>”已导入
gpg: 合计被处理的数量:1
gpg:               已导入:1
pct@Chandler:~/workspace/ABA/Codes/Eos-Env/eos$ echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse
pct@Chandler:~/workspace/ABA/Codes/Eos-Env/eos$ sudo apt-get update
pct@Chandler:~/workspace/ABA/Codes/Eos-Env/eos$ sudo apt-get install -y mongodb-org=3.6.3 mongodb-org-server=3.6.3 mongodb-org-shell=3.6.3 mongodb-org-mongos=3.6.3 mongodb-org-tools=3.6.3

代码分析:

文件中的代码如下:

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif

#include_next <wchar.h>

#elif !defined(_LIBCPP_WCHAR_H)
#define _LIBCPP_WCHAR_H

include_next表示添加搜索到的第二个目录下的wchar.h文件,我们在系统目录下并没有看到这个文件。 解决方案: 升级系统到最新系统,重新下载Xcode和源码,重新编译就OK了。

运行测试

首先进入 eos/build/programs 执行make install,建立本地的网络,然后进入 eos/build/programs/nodeos 目录下,运行nodes可执行文件,此时会在eos/build目录下生成一个etc目录,里面存放基础的配置文件:

ChandlerPandeMacBook-Pro:etc chandler$ tree
.
└── eosio
    ├── launcher
    │   └── testnet.template
    └── node_00
        ├── config.ini
        └── genesis.json

3 directories, 3 files

我们可以修改config.ini文件来实现自己的配置。 修改下面的几个配置:

# Enable block production, even if the chain is stale. (eosio::producer_plugin)
enable-stale-production = false
# ID of producer controlled by this node (e.g. inita; may specify multiple times) (eosio::producer_plugin)
# producer-name = 
# Plugin(s) to enable, may be specified multiple times
# plugin = 

修改为:

# Enable block production, even if the chain is stale. (eosio::producer_plugin)
enable-stale-production = true
# ID of producer controlled by this node (e.g. inita; may specify multiple times) (eosio::producer_plugin)
producer-name = panchangtao
# Plugin(s) to enable, may be specified multiple times
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

重新运行,打印如下:

ChandlerPandeMacBook-Pro:nodeos chandler$ ./nodeos 
2300126ms thread-0   chain_plugin.cpp:96           plugin_initialize    ] initializing chain plugin
2300126ms thread-0   wallet_plugin.cpp:37          plugin_initialize    ] initializing wallet plugin
2300126ms thread-0   http_plugin.cpp:141           plugin_initialize    ] host: 127.0.0.1 port: 8888 
2300126ms thread-0   http_plugin.cpp:144           plugin_initialize    ] configured http to listen on 127.0.0.1:8888
2300126ms thread-0   net_plugin.cpp:2624           plugin_initialize    ] Initialize net plugin
2300126ms thread-0   net_plugin.cpp:2646           plugin_initialize    ] Setting net_plugin logging level to info
2300126ms thread-0   net_plugin.cpp:2674           plugin_initialize    ] host: 0.0.0.0 port: 9876 
2300126ms thread-0   net_plugin.cpp:2750           plugin_initialize    ] my node_id is c0dc69241cede0f2f3c35f02a4fc7f623df9d4afad76101d663a7933205c100c
2300127ms thread-0   main.cpp:110                  main                 ] nodeos version 1dae6391
2300127ms thread-0   main.cpp:111                  main                 ] eosio root is /Users/chandler/work/eos/build
2300148ms thread-0   chain_plugin.cpp:205          plugin_startup       ] starting chain in read/write mode
2300148ms thread-0   chain_plugin.cpp:210          plugin_startup       ] Blockchain started; head block is #0, genesis timestamp is 2017-03-30T12:00:00.000
2300148ms thread-0   producer_plugin.cpp:161       plugin_startup       ] producer plugin:  plugin_startup() begin
2300148ms thread-0   producer_plugin.cpp:166       plugin_startup       ] Launching block production for 1 producers.

*******************************
*                             *
*   ------ NEW CHAIN ------   *
*   -  Welcome to EOSIO!  -   *
*   -----------------------   *
*                             *
*******************************

Your genesis seems to have an old timestamp
Please consider using the --genesis-timestamp option to give your genesis a recent timestamp

2300149ms thread-0   producer_plugin.cpp:176       plugin_startup       ] producer plugin:  plugin_startup() end
2300149ms thread-0   http_plugin.cpp:156           plugin_startup       ] start processing http thread
2300149ms thread-0   http_plugin.cpp:213           plugin_startup       ] start listening for http requests
2300149ms thread-0   http_plugin.cpp:218           plugin_startup       ] http io service exit
2300149ms thread-0   wallet_api_plugin.cpp:70      plugin_startup       ] starting wallet_api_plugin
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/create
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/get_public_keys
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/import_key
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/list_keys
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/list_wallets
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/lock
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/lock_all
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/open
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/set_timeout
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/sign_transaction
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/wallet/unlock
2300149ms thread-0   chain_api_plugin.cpp:62       plugin_startup       ] starting chain_api_plugin
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/abi_bin_to_json
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/abi_json_to_bin
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/get_account
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/get_block
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/get_code
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/get_currency_balance
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/get_currency_stats
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/get_info
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/get_required_keys
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/get_table_rows
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/push_block
2300149ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/push_transaction
2300150ms thread-0   http_plugin.cpp:242           add_handler          ] add api url: /v1/chain/push_transactions
2300150ms thread-0   net_plugin.cpp:2762           plugin_startup       ] starting listener, max clients is 25
2300505ms thread-0   producer_plugin.cpp:244       block_production_loo ] Not producing block because it isn't my turn, its eosio

程序是运行起来了,但是并没有产生区块,看来是某些配置还是有问题。 上面配置中的name需要改成eosio才能产生区块,看来这个是固定好的。

Tags: