节点连接
创建文件夹,复制.json过来,创建文件夹data0,初始化
geth --datadir data0 init genesis.json
然后
geth --identity "SCAU" --rpc --rpcport "8545" --datadir data0 --port "30303" --rpcapi "db,eth,net,web3" --allow-insecure-unlock --networkid 65534 --nodiscover console
这样一个节点便创建好了
然后再在.json文件和data0所在的文件创建另一个节点
建立文件夹data1,初始化
geth --datadir data1 init genesis.json
然后
geth --identity "SCAU" --rpc --rpcport "8546" --datadir data1 --port "30304" --rpcapi "db,eth,net,web3" --allow-insecure-unlock --networkid 65534 --nodiscover console
注意改一下rpcport和port
在data0和data1中输入
geth attach ipc:geth.ipc
然后查看节点标识
admin.nodeInfo.enode
将节点1的节点标识复制到节点2,也就是如下
节点连接
admin.addPeer("enode://4923254425942156a684eebd06f2371f2601b8d4a55e80d9800930715a54da5f3fea189ea99a2d0e573c7efb68b7e35ed14d02657fe674d58abd0f83e4c24dc6@127.0.0.1:3002?discport=0")
查看节点是否连接
admin.peers
查看已连接的节点数量
net.peerCount
看节点1和节点2数据是否完全同步
节点连接后需要同步数据,需要一点时间,如果你的创世区块id和别人的一样,你可能会同步别人的节点
关掉节点1的挖矿,在节点2查一下节点1的余额
节点1向节点2转账,转账成功说明同步完成
eth.sendTransaction({from: eth.coinbase, to: "0x7992d63ef38d07aeca3ca0958fb751b60038fc41", value: 66666666})