3, 开始挖矿
3.1 开启bootnode
$ bootnode -nodekey boot.key -verbosity 9 -addr :30310 // 请勿使用 30303
3.2 开启矿工节点
$geth --datadir node1/ --syncmode 'full' --port 30311 --rpc --rpcaddr 'localhost' --rpcport 8551 --rpcapi 'personal,db,eth,net,web3,txpool,miner' --bootnodes 'enode://3ec4fef2d726c2c01f16f0a0030f15dd5a81e274067af2b2157cafbf76aa79fa9c0be52c6664e80cc5b08162ede53279bd70ee10d024fe86613b0b09e1106c40@127.0.0.1:30310' --networkid 1515 --gasprice '1' --unlock '0x87366ef81db496edd0ea2055ca605e8686eec1e6' --password node1/password.txt --mine
$ geth --datadir node2/ --syncmode 'full' --port 30312 --rpc --rpcaddr 'localhost' --rpcport 8552 --rpcapi 'personal,db,eth,net,web3,txpool,miner' --bootnodes 'enode://3ec4fef2d726c2c01f16f0a0030f15dd5a81e274067af2b2157cafbf76aa79fa9c0be52c6664e80cc5b08162ede53279bd70ee10d024fe86613b0b09e1106c40@127.0.0.1:30310' --networkid 1515 --gasprice '0' --unlock '0x08a58f09194e403d02a1928a7bf78646cfc260b0' --password node2/password.txt --mine
控制台命令参数解析:
--datadir 指定链的数据位置
--syncmode
‘full’:节点同步所有区块头 区块数据以及签名 ,并验证区块
‘fast’:节点同步区块头和区块数据,不做任何校验,类似于“快照”
‘light’:节点直接从其他‘full’节点同步当前状态
--rpcapi 会使用那些api与此节点交互
--rpcaddr 这个节点监听从哪里发来的rpc请求
--rpcport 这个节点监听从哪个端口发来的rpc请求
--bootnodes 指定bootnode ID
--networkid 同一个链上节点networkid相同
--gasprice 这个矿工节点可以接受的最小gas
--mine 开始挖矿
3.3 创建第三个节点
$mkdir node3
$geth --datadir node3/ account new
$echo {ACCOUNT3} >> accounts.txt
$echo {PASSWD3} > node3/password.txt
$geth --datadir node3/ init genesis.json
3.4 已存在节点投票加入新节点
进入node1的控制台
$geth attach node1/geth.ipc
投票加入node3的地址
>clique.propose( {ACCOUNT3}, true)
>exit
同上
$geth attach node2/geth.ipc
>clique.propose( {ACCOUNT}, true)
>exit
$ geth --datadir node3/ --syncmode 'full' --port 30313 --rpc --rpcaddr 'localhost' --rpcport 8553 --rpcapi 'personal,db,eth,net,web3,txpool,miner' --bootnodes 'enode://3ec4fef2d726c2c01f16f0a0030f15dd5a81e274067af2b2157cafbf76aa79fa9c0be52c6664e80cc5b08162ede53279bd70ee10d024fe86613b0b09e1106c40@127.0.0.1:30310' --networkid 1515 --gasprice '0' --unlock '0x08a58f09194e403d02a1928a7bf78646cfc11ab3' --password node3/password.txt --mine
网友评论