EOS学习教程(三)-- nodeos连接主网

2019-11-07  本文已影响0人  SuperGino

1.创建文件夹

因为我们本地还搭建了测试网的信息,为了不冲突,所以创建新的文件夹放主网的配置文件和区块数据

mkidr /Users/<Your Name>/Documents/data/EOSData/MainNet
#配置文件路径
mkidr /Users/<Your Name>/Documents/data/EOSData/MainNet/config
#区块数据同步路径
mkidr /Users/<Your Name>/Documents/data/EOSData/MainNet/data

2.修改config.ini配置文件

默认文件路径 /Users/<Your Name>/Library/Application\ Support/eosio/nodeos/config/config.ini
我们就不修改默认的文件路径,我们新建一个文件在上面的文件夹里面
/Users/<Your Name>/Documents/data/EOSData/MainNet/config
CryptoLions提供了主网的配置文件config.ini给大家参考
https://github.com/CryptoLions/EOS-MainNet/blob/master/config.ini

agent-name = GinoAgentName
#blocks-dir = "blocks"
chain-state-db-size-mb = 65536
reversible-blocks-db-size-mb = 2048
http-server-address = 0.0.0.0:8888
p2p-server-address = 0.0.0.0:9876
http-validate-host = false
verbose-http-errors = true  
abi-serializer-max-time-ms = 2000  
chain-threads = 8
http-threads = 6
access-control-allow-origin = *
access-control-allow-headers = Origin, X-Requested-With, Content-Type, Accept
wasm-runtime = wabt
last-block-time-offset-us = -300000
p2p-max-nodes-per-host = 150
max-clients = 150
sync-fetch-span = 2000

plugin = eosio::chain_api_plugin
plugin = eosio::history_plugin
plugin = eosio::history_api_plugin
plugin = eosio::chain_plugin
    

p2p-peer-address = api-full1.eoseoul.io:9876
p2p-peer-address = api-full2.eoseoul.io:9876
p2p-peer-address = boot.eostitan.com:9876
p2p-peer-address = bp.cryptolions.io:9876
p2p-peer-address = bp.eosbeijing.one:8080
p2p-peer-address = bp.libertyblock.io:9800
p2p-peer-address = br.eosrio.io:9876
p2p-peer-address = eos-seed-de.privex.io:9876
p2p-peer-address = eu1.eosdac.io:49876
p2p-peer-address = fullnode.eoslaomao.com:443
p2p-peer-address = mainnet.eoscalgary.io:5222
p2p-peer-address = node.eosflare.io:1883
p2p-peer-address = node1.eoscannon.io:59876
p2p-peer-address = node1.eosnewyork.io:6987
p2p-peer-address = node2.eosnewyork.io:6987
p2p-peer-address = p2p.eosdetroit.io:3018
p2p-peer-address = p2p.genereos.io:9876
p2p-peer-address = p2p.meet.one:9876
p2p-peer-address = peer.eosn.io:9876
p2p-peer-address = peer.main.alohaeos.com:9876
p2p-peer-address = peer1.mainnet.helloeos.com.cn:80
p2p-peer-address = peer2.mainnet.helloeos.com.cn:80
p2p-peer-address = peering.mainnet.eoscanada.com:9876
p2p-peer-address = peering1.mainnet.eosasia.one:80
p2p-peer-address = peering2.mainnet.eosasia.one:80
p2p-peer-address = publicnode.cypherglass.com:9876

3.新建主网的创世文件genesis.json

在config.ini文件旁边建立一个genesis.json文件,然后nodeos启动的时候指定路径
CryptoLions也提供了主网的创世文件genesis.json给大家参考
https://github.com/CryptoLions/EOS-MainNet/blob/master/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
  }
}

4.启动节点

--config-dir指定配置文件夹的路径 --data-dir 指定同步数据的路径
第一次启动节点时最好时清空所有区块数据,添加参数 --delete-all-blocks,第二次启动不需要,不然每次都要重新同步一次的数据

./nodeos  --config-dir /Users/<Your Name>/Documents/data/EOSData/MainNet/config --data-dir /Users/<Your Name>/Documents/data/EOSData/MainNet/data --genesis-json /Users/<Your Name>/Documents/data/EOSData/MainNet/config/mainnet-genesis.json --delete-all-blocks

4.检查是否正常

./cleos get info 

{
  "server_version": "7d210b38",
  "chain_id": "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906",
  "head_block_num": 1374,
  "last_irreversible_block_num": 1373,
  "last_irreversible_block_id": "0000055d0a89de53b028bb49c8ca335d32d6aafe1dcff7508c7df27a196255d3",
  "head_block_id": "0000055e19d8d6e733c7b87092d9315ec9b6107b469a670a363888d5d0ad6178",
  "head_block_time": "2018-06-09T12:09:40.000",
  "head_block_producer": "eosio",
  "virtual_block_cpu_limit": 257917810,
  "virtual_block_net_limit": 4140299,
  "block_cpu_limit": 100000000,
  "block_net_limit": 1048576,
  "server_version_string": "v1.8.5-6-g7d210b387",
  "fork_db_head_block_num": 1374,
  "fork_db_head_block_id": "0000055e19d8d6e733c7b87092d9315ec9b6107b469a670a363888d5d0ad6178"
}

看到 "chain_id": "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906",代表以及连接到主网,等待head_block_num和主网最新去看号一致就说明同步完成

上一篇下一篇

猜你喜欢

热点阅读