下载源码

EOS 代码使用了三个子模块

  • 插件管理模块 AppBase
  • 区块链结构模块 ChainBase
  • WASM 模块

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

所以上面需要用recursive,如果没有带有recursive下载了eos,可以通过如下方式下载submodules

cd eos

git submodule update --init --recursive

国内目前从github下载源码速度很慢,可以参考我这篇博文【github访问慢和clone慢解决方案】提速

编译

编译其实很简单,就是执行脚本

./eosio_build.sh

mac平台编译依赖homebrew工具,所以必须先安装好homebrew工具

ruby -e "$(curl -fsSL

https://raw.githubusercontent.com/Homebrew/install/master/install

)"

如果你的电脑内存

< 8G会报如下错误

itleaks@itleaks-VirtualBox:~/projects/eos$

./eosio_build.sh

Beginning build version: 1.2

2018年 05月 18日 星期五 07:13:36 UTC

User: itleaks

git head id: 29c30f10650102ffb000bb1a287dc285d582275f

Current branch: master


ARCHITECTURE: Linux

OS name: Ubuntu

OS Version: 16.04

CPU speed: 3095.998Mhz

CPU cores: 1

Physical Memory: 1993 Mgb

Disk install: /dev/sda1

Disk space total: 47G

Disk space available: 31G

Your system must have 7 or more Gigabytes of physical memory installed.

Exiting now.

如果你想绕开这个限制,可以修改相应的脚本文件

VirtualBox:~/projects/eos$ grep "Your system must have" . -rn

./scripts/eosio_build_ubuntu.sh:28: printf "\tYour system must have 7 or more Gigabytes of physical memory installed.\n"

./scripts/eosio_build_darwin.sh:29: echo "Your system must have 7 or more Gigabytes of physical memory installed."

./scripts/eosio_build_fedora.sh:25: printf "\tYour system must have 7 or more Gigabytes of physical memory installed.\n"

./scripts/eosio_build_amazon.sh:21: printf "\tYour system must have 7 or more Gigabytes of physical memory installed.\n"

./scripts/eosio_build_centos.sh:26: printf "\n\tYour system must have 7 or more Gigabytes of physical memory installed.\n"

比如ubuntu平台就修改

./scripts/eosio_build_ubuntu.sh文件,将下面的7000修改即可

编译时会自动下载依赖库

$./eosio_build.sh

Checking dependencies.

Checking automake ... automake NOT found.

Checking Libtool ... Libtool

NOT

found.

Checking OpenSSL ... OpenSSL NOT found.

Checking llvm ...

llvm

NOT found.

Checking wget ... wget NOT found.

Checking CMake ... CMake NOT found.

Checking GMP ... GMP NOT found.

Checking gettext ... gettext NOT found.

Checking MongoDB ... MongoDB NOT found.

Checking Doxygen ... Doxygen NOT found.

Checking Graphviz ... Graphviz NOT found.

Checking LCOV ... LCOV NOT found.

Checking Python3 ... python3 NOT found.

The following dependencies are required to install EOSIO.

  1. automake\n\t2. Libtool\n\t3. OpenSSL\n\t4. llvm\n\t5. wget\n\t6. CMake\n\t7. GMP\n\t8. gettext\n\t9. MongoDB\n\t10. Doxygen\n\t11. Graphviz\n\t12. LCOV\n\t13. Python 3\n\t

这个依赖库下载过程是非常慢,其中llvm耗时最久,最好的办法是使用vpn,否则真的就是龟速。

最后编译成功会显示如下信息:

启动节点服务程序

EOS主要有三个程序:

ubuntu@ip-172-31-28-214:/data/d01/data/eos/build$ ls programs/ -alh

total 52K

drwxrwxr-x 9 ubuntu ubuntu 4.0K May 18 07:45 .

drwxrwxr-x 16 ubuntu ubuntu 4.0K May 18 08:00 ..

drwxrwxr-x 3 ubuntu ubuntu 4.0K May 18 07:52 cleos

drwxrwxr-x 3 ubuntu ubuntu 4.0K May 18 07:50 keosd

drwxrwxr-x 3 ubuntu ubuntu 4.0K May 18 07:53 nodeos

  • cloes:客户端命令行交互模块,用于解析用户命令,根据具体命令请求调用相应的接口,例如查看区块信息、操作钱包等等。
  • nodeos:服务器端,也就是区块生产节点,用于接受客户端的远端请求,并打包区块,主要包含四个插件,chain_plugin、http_plugin、net_plugin、producer_plugin。
  • keosd:钱包管理模块,主要包括三个插件,wallet_plugin、wallet_api_plugin、http_plugin。

启动nodeos,命令如下

./nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin

如果不带参数执行nodeos程序,会如下错误

重启启动nodeos程序,结果如下,可见已经能挖出block了

安装开发工具

比如eosiocpp工具,Include, library库安装,这些在开发智能合约时用的上

cd build

sudo make install

results matching ""

    No results matching ""