geth 搭建联盟链

geth可以使用poa的方式搭建联盟链,联盟链可以指定几个节点进行挖矿,其它节点没有挖矿的权限

一、创世区块:

{
    "config": {
      "chainId": 19,
      "homesteadBlock": 1,
      "eip150Block": 2,
      "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "eip155Block": 3,
      "eip158Block": 3,
      "byzantiumBlock": 4,
      "clique": {
        "period": 0,
        "epoch": 30000
      }
    },
    "nonce": "0x0",
    "timestamp": "0x5b03bb37",
    "extraData": "0x00000000000000000000000000000000000000000000000000000000000000001ad1385690b71f20e123214bf0ee091972448da3cc01b9379b433ced8e4cd2abe5e2528a62502cbb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "gasLimit": "0x47b760",
    "difficulty": "0x1",
    "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "coinbase": "0x0000000000000000000000000000000000000000",
    "alloc": {
      "1ad1385690b71f20e123214bf0ee091972448da3": {
        "balance": "0x200000000000000000000000000000000000000000000000000000000000000"
      },
      "cc01b9379b433ced8e4cd2abe5e2528a62502cbb": {
        "balance": "0x200000000000000000000000000000000000000000000000000000000000000"
      }
    },
    "number": "0x0",
    "gasUsed": "0x0",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"

}


二、启动挖矿节点:

nohup ./geth --datadir /home/ytf/soft/go-ethereum-master-1.8.4/build/bin/poaChain/ --syncmode "full" --port 30311 --rpc --rpcaddr "localhost" --rpcport 8501 --rpcapi "personal,db,eth,net,web3,txpool,miner,net" --bootnodes "enode://7ffc9d04fd47669cce51c0ff4c5affd38a74f2274b8f58ae64e7d26e8d472f62e4e6d3607d3c4c78dc17e3b30df9d0de2a9054b9e9957f8cfda98654dbd396cf@172.16.16.141:30310" --networkid 19 --gasprice "1" -unlock "0xcc01b9379b433ced8e4cd2abe5e2528a62502cbb" --password /home/ytf/soft/go-ethereum-master-1.8.4/build/bin/poaChain/password.txt --mine &

三、启动其它节点:

nohup ./geth --datadir /home/ytf/soft/go-ethereum-master-1.8.4/build/bin/poaChain/ --syncmode "full" --port 30311 --rpc --rpcaddr "localhost" --rpcport 8501 --rpcapi "personal,db,eth,net,web3,txpool,miner,net" --bootnodes "enode://7ffc9d04fd47669cce51c0ff4c5affd38a74f2274b8f58ae64e7d26e8d472f62e4e6d3607d3c4c78dc17e3b30df9d0de2a9054b9e9957f8cfda98654dbd396cf@172.16.16.141:30310" --networkid 19 --gasprice "1" &

四、查看效果:

在挖矿节点执行miner.start(),发现有交易时交易上链,在非挖矿节点启动,无法挖矿。



你可能感兴趣的:(geth 搭建联盟链)