区块链之添加节点

1.查询节点信息

> admin.nodeInfo
{
  enode: "enode://b817560f061b1f14551f87060806847c4c6b7cf8b56b6027fd3d8400c3abb4e2a3d535dd78ab46f28d0862a3cd1b78f74f48fa51e1ad4b583502991a5faa71a0@[::]:30303",
  id: "b817560f061b1f14551f87060806847c4c6b7cf8b56b6027fd3d8400c3abb4e2a3d535dd78ab46f28d0862a3cd1b78f74f48fa51e1ad4b583502991a5faa71a0",
  ip: "::",
  listenAddr: "[::]:30303",
  name: "Geth/v1.8.0-unstable-9d06026c/darwin-amd64/go1.9.2",
  ports: {
    discovery: 30303,
    listener: 30303
  },
  protocols: {
    eth: {
      config: {
        chainId: null,
        eip150Hash: "0x0000000000000000000000000000000000000000000000000000000000000000"
      },
      difficulty: 9110924474,
      genesis: "0x782133132c2e1db8f94aab3b907a51cfb3b01ff71d365567c772517f4d7592dc",
      head: "0xd2c74746b96f9a77122c47b09480fcf745555c9373a32b3f913f07efcd4da1bb",
      network: 1
    }
  }
}

2.添加节点

> admin.addPeer('enode://505f5d3e92fe4b62618319a8bade10d0bc6df7feafe39186b54cbc459137f98637da0b613a967451fb6e7d3aa70491e8e63def0bf052fe84cc891bd41fbe6206@[ip]:30303')
true
> admin.peers
[{
    caps: ["eth/62", "eth/63"],
    id: "505f5d3e92fe4b62618319a8bade10d0bc6df7feafe39186b54cbc459137f98637da0b613a967451fb6e7d3aa70491e8e63def0bf052fe84cc891bd41fbe6206",
    name: "Geth/v1.8.0-unstable-5e1581c2/linux-amd64/go1.8.3",
    network: {
      localAddress: "10.13.70.9:55412",
      remoteAddress: "ip:30303"
    },
    protocols: {
      eth: {
        difficulty: 524736,
        head: "0x1b872eb878231b4ec06b20b001570f966f4031172ec77e563d39bbd13f25fdda",
        version: 63
      }
    }
}]

3.同步区块

> eth.blockNumber
11089

 

你可能感兴趣的:(区块链)