连接EOS主网
一、从github克隆主网代码仓库:
git clone https://github.com/EOS-Mainnet/eos
二、更新代码仓库子模块,使用递归参数
git submodule update --init --recursive
三、git tag命令查看版本标签
git tag
四、将本地仓库代码切换到mainnet-1.0.2.2版本
git checkout mainnet-1.0.2.2
五、git branch 查看本地仓库代码版本是否mainnet-1.0.2.2
git branch
六、编译代码之前,使用查找替换,把代码中eosio的公钥:EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
替换成后面这个:EOS7EarnUhcyYqmdnPon8rm7mBCTnBoot6o7fE2WzjvEX2TdggbL3
七、运行自动化编译脚本:./eosio_build.sh,对代码进行编译
./eosio_build.sh
自动化编译过程可能会因为主机物理内存小于7G,boost库,mongodb等下载失败或其他原因而编译失败,请查找原因或修改脚本自行解决。
八、config.ini文件内容如下
# fullnode sample configblocks-dir = "blocks"chain-state-db-size-mb = 1024reversible-blocks-db-size-mb = 340contracts-console = falsehttps-client-validate-peers = 1http-server-address = 0.0.0.0:8888access-control-allow-credentials = falsep2p-listen-endpoint = 0.0.0.0:9876p2p-server-address = 0.0.0.0:9876# List of peersp2p-peer-address = p2p.one.eosdublin.io:9876p2p-peer-address = eu-west-nl.eosamsterdam.net:9876p2p-peer-address = p2p.mainnet.eosgermany.online:9876p2p-peer-address = 35.197.190.234:19878p2p-peer-address = p2p.genereos.io:9876p2p-peer-address = fullnode.eoslaomao.com:443p2p-peer-address = new.eoshenzhen.io:10034p2p-peer-address = node1.eosphere.io:9876p2p-peer-address = p2p.meet.one:9876p2p-peer-address = bp.eosbeijing.one:8080p2p-peer-address = peer1.mainnet.helloeos.com.cn:80p2p-peer-address = p2p-public.hkeos.com:19875p2p-peer-address = pub1.eostheworld.io:9876p2p-peer-address = eu1.eosdac.io:49876p2p-peer-address = peer.eosio.sg:9876p2p-max-nodes-per-host = 10agent-name = "kevincaokun1"# allowed-connection can be set to "specified" to use whitelisting with the "peer-key" optionallowed-connection = any# peer-private-key is needed if you are whitelisting specific peers with the "peer-key" optionpeer-private-key = ["EOS6qTvpRYx35aLonqUkWAMwAf3mFVugYfQCbjV67zw2aoe7Vx7qd", "5JroNC1B4pz9gJzNZeU7tkU6YMtoeWRCr4CJJwKsVXnJhRbKXSC"]max-clients = 250connection-cleanup-period = 30network-version-match = 1sync-fetch-span = 100max-implicit-request = 1500enable-stale-production = falsepause-on-startup = falsemax-transaction-time = 10000max-irreversible-block-age = -1txn-reference-block-lag = 0# Plugins used for full nodesplugin = eosio::chain_api_pluginplugin = eosio::history_api_pluginplugin = eosio::chain_pluginplugin = eosio::history_pluginplugin = eosio::net_pluginplugin = eosio::net_api_plugin
九、创世json文件genesis.json 内容如下:
{"initial_timestamp": "2018-06-08T08:08:08.888","initial_key": "EOS7EarnUhcyYqmdnPon8rm7mBCTnBoot6o7fE2WzjvEX2TdggbL3","initial_configuration": {"max_block_net_usage": 1048576,"target_block_net_usage_pct": 1000,"max_transaction_net_usage": 524288,"base_per_transaction_net_usage": 12,"net_usage_leeway": 500,"context_free_discount_net_usage_num": 20,"context_free_discount_net_usage_den": 100,"max_block_cpu_usage": 200000,"target_block_cpu_usage_pct": 1000,"max_transaction_cpu_usage": 150000,"min_transaction_cpu_usage": 100,"max_transaction_lifetime": 3600,"deferred_trx_expiration_window": 600,"max_transaction_delay": 3888000,"max_inline_action_size": 4096,"max_inline_action_depth": 4,"max_authority_depth": 6}}
十、config.ini和genesis.json文件放置路径
- linux-ubuntu: ~/.local/share/eosio/nodeos/config/
- mac-osx: ~/Library/Application\ Support/eosio/nodeos/data/config
十一、启动nodeos前注意:清理旧的数据
十二、使用nodeos -v 查看 nodeos的版本是否 :3679913985
nodeos -v
十三、nodeos启动后使用 cleos get info 命令查看链的chain_id 是否下面这行代码: aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906
十四、注意如果chain_id不对,则不是主网的链,不会从主网同步数据,遇到这种情况请使用下面命令重新启动nodeos,注意路径和你主机上nodeos 所在的路径一致,并且把genesis.json文件拷贝到该目录下面
cd ~/eos/build/program/nodeos./nodeos --genesis-json genesis.json
十五、区块数据正常同步以后,可以使用cleos命令行对链条进行一些操作,比如:查看191块的数据
cleos get block 191
发现这个191区块存在这样一笔交易,eosio 账户给 b1账户转了 10个EOS,并且备注了这样一句话:
Never doubt that a small group of thoughtful, committed citizens can change the world; indeed, it's the only thing that ever has - eosacknowledgments.io
翻译成中文是:
永远不要怀疑一小群有思想、有责任心的公民能改变世界,事实上,这是唯一的事情。
如果想看以上命令的执行结果截图,请参考 https://blog.csdn.net/caokun_8341/article/details/80656765
