EOS 主节点同步

一.从github克隆主网代码仓库

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

 

二.编译与安装EOS环境

cd ~/eos
./eosio_build.sh  

编译成功后会输出如下:

 

三.设置环境

sudo make install  

 

四.修改配置文件

1.先运行一次 ./nodeos,报错后会产生文件夹 ~/.local   把下面的config.ini文件替换默认的config.ini文件,文件放在 ~/.local/share/eosio/nodeos/config路径下。

# fullnode sample config  
  
blocks-dir = "blocks"  
  
chain-state-db-size-mb = 1024  
  
reversible-blocks-db-size-mb = 340  
  
contracts-console = false  
  
https-client-validate-peers = 1  
  
http-server-address = 0.0.0.0:8888  
  
access-control-allow-credentials = false  
  
p2p-listen-endpoint = 0.0.0.0:9876  
  
p2p-server-address = 0.0.0.0:9876  
  
  
  
# List of peers  
  
p2p-peer-address = p2p.one.eosdublin.io:9876  
  
p2p-peer-address = eu-west-nl.eosamsterdam.net:9876  
  
p2p-peer-address = p2p.mainnet.eosgermany.online:9876  
  
p2p-peer-address = 35.197.190.234:19878  
  
p2p-peer-address = p2p.genereos.io:9876  
  
p2p-peer-address = fullnode.eoslaomao.com:443  
  
p2p-peer-address = new.eoshenzhen.io:10034  
  
p2p-peer-address = node1.eosphere.io:9876  
  
p2p-peer-address = p2p.meet.one:9876  
  
p2p-peer-address = bp.eosbeijing.one:8080  
  
p2p-peer-address = peer1.mainnet.helloeos.com.cn:80  
  
p2p-peer-address = p2p-public.hkeos.com:19875  
  
p2p-peer-address = pub1.eostheworld.io:9876  
  
p2p-peer-address = eu1.eosdac.io:49876  
  
p2p-peer-address = peer.eosio.sg:9876  
  
p2p-max-nodes-per-host = 10  
    
agent-name = "kevincaokun1"  
  
# allowed-connection can be set to "specified" to use whitelisting with the "peer-key" option  
  
allowed-connection = any  
  
# peer-private-key is needed if you are whitelisting specific peers with the "peer-key" option  
  
peer-private-key = ["EOS6qTvpRYx35aLonqUkWAMwAf3mFVugYfQCbjV67zw2aoe7Vx7qd", "5JroNC1B4pz9gJzNZeU7tkU6YMtoeWRCr4CJJwKsVXnJhRbKXSC"]  
  
max-clients = 250  
  
connection-cleanup-period = 30  
  
network-version-match = 1  
  
sync-fetch-span = 100  
  
max-implicit-request = 1500  
  
enable-stale-production = false  
  
pause-on-startup = false  
  
max-transaction-time = 10000  
  
max-irreversible-block-age = -1  
  
txn-reference-block-lag = 0  
  
# Plugins used for full nodes  
  
plugin = eosio::chain_api_plugin  
  
plugin = eosio::history_api_plugin  
  
plugin = eosio::chain_plugin  
  
plugin = eosio::history_plugin  
  
plugin = eosio::net_plugin  
  
plugin = eosio::net_api_plugin

 

2.创建一个创世json文件genesis.json ,放在 ~/eos/build/program/nodeos路径下,文件内容如下:

{  
  "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  
  }  
}

 

五.启动nodeos

  如果使用以前原有的工程,请先清除掉 ~/.local/share/eosio/nodeos/data 文件夹和~/eosio-wallet文件夹,做好准备工作后,启动节点:

cd ~/eos/build/program/nodeos  
./nodeos --genesis-json genesis.json

 

六.查看同步数据

使用命令 

cleos get info 

输出如下:

hml@Ulord-19:~/.local/share/eosio/nodeos$ cleos get info
{
  "server_version": "c9b7a247",
  "chain_id": "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906",
  "head_block_num": 308445,
  "last_irreversible_block_num": 308444,
  "last_irreversible_block_id": "0004b4dcd70b982d37dc2be431ce59c514bb29c6f461449277225dc4aa61956c",
  "head_block_id": "0004b4ddb85592d3625080d80ec1820b06cc3d1a2d11ea4679c16956a6b19ee0",
  "head_block_time": "2018-06-12T05:48:31.500",
  "head_block_producer": "genesisblock",
  "virtual_block_cpu_limit": 200000000,
  "virtual_block_net_limit": 1048576000,
  "block_cpu_limit": 199900,
  "block_net_limit": 1048576
}

  其中chain_id的值为aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906说明已经设置成功了,还可以获取区块191的信息,输入以下命令:

cleos get block 191

会输出以下内容:

{
  "timestamp": "2018-06-09T11:58:04.500",
  "producer": "eosio",
  "confirmed": 0,
  "previous": "000000be7ec418241839c376b35a4ae88b305e045a4f0e779215c5f5f4508e5d",
  "transaction_mroot": "1f09d60c3b791e1fa29e7fe980807ec36fab1c9fbc130f72f492e3b4c965184b",
  "action_mroot": "1ca50b0889e5c6b884e621ff113b17868dfbbc7cd2d4549784c8e50a5114e75c",
  "schedule_version": 0,
  "new_producers": null,
  "header_extensions": [],
  "producer_signature": "SIG_K1_K87sojWELjnYSUvpS1Xy1L1P5Etr7xrcnuauqM5zoUYZRTL6eLXA9fZASdvH1ynUq1ZXSceNqWGrcAxj6cZt3ERvgk2aD9",
  "transactions": [{
      "status": "executed",
      "cpu_usage_us": 1593,
      "net_usage_words": 35,
      "trx": {
        "id": "ad77575a8b4f52e477682e712b1cbd884299468db6a94d909f90c6961cea9b02",
        "signatures": [
          "SIG_K1_KfUNC7KHjSGKBrk8FHjq9tqZA12q1aD9pspfBbLW9iw58B6DqoyebmLaEP2VUuJZa2nDZ11YdgEi2VwuqY5sSogh7MaG8p"
        ],
        "compression": "none",
        "packed_context_free_data": "",
        "context_free_data": [],
        "packed_trx": "eac01b5bbd00421775ad000000000100a6823403ea3055000000572d3ccdcd010000000000ea305500000000a8ed3232ba010000000000ea30550000000000004038a08601000000000004454f530000000098014e6576657220646f7562742074686174206120736d616c6c2067726f7570206f662074686f7567687466756c2c20636f6d6d697474656420636974697a656e732063616e206368616e67652074686520776f726c643b20696e646565642c206974277320746865206f6e6c79207468696e672074686174206576657220686173202d20656f7361636b6e6f776c6564676d656e74732e696f00",
        "transaction": {
          "expiration": "2018-06-09T11:58:34",
          "ref_block_num": 189,
          "ref_block_prefix": 2910132034,
          "max_net_usage_words": 0,
          "max_cpu_usage_ms": 0,
          "delay_sec": 0,
          "context_free_actions": [],
          "actions": [{
              "account": "eosio.token",
              "name": "transfer",
              "authorization": [{
                  "actor": "eosio",
                  "permission": "active"
                }
              ],
              "data": {
                "from": "eosio",
                "to": "b1",
                "quantity": "10.0000 EOS",
                "memo": "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"
              },
              "hex_data": "0000000000ea30550000000000004038a08601000000000004454f530000000098014e6576657220646f7562742074686174206120736d616c6c2067726f7570206f662074686f7567687466756c2c20636f6d6d697474656420636974697a656e732063616e206368616e67652074686520776f726c643b20696e646565642c206974277320746865206f6e6c79207468696e672074686174206576657220686173202d20656f7361636b6e6f776c6564676d656e74732e696f"
            }
          ],
          "transaction_extensions": []
        }
      }
    }
  ],
  "block_extensions": [],
  "id": "000000bf87a9db45034a46671514a225cb1a5c30e9b8dc172bc75ef30a812970",
  "block_num": 191,
  "ref_block_prefix": 1732659715
}

发现这个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

翻译成中文是:永远不要怀疑一小群有思想、有责任心的公民能改变世界,事实上,这是唯一的事情。

 

posted @ 2018-06-28 11:53  HBright  阅读(1020)  评论(0编辑  收藏  举报