查看自己节点信息
admin.nodeInfo
{
enode: "enode://0911f6d8c58bb0013fe520fc63282c50892a1c1e2a6c3b2471572491673f849790a275d0f827afb4fcd1140f84f320ae33f370ca420d9889ea635e054205d14c@[::]:8000",
id: "0911f6d8c58bb0013fe520fc63282c50892a1c1e2a6c3b2471572491673f849790a275d0f827afb4fcd1140f84f320ae33f370ca420d9889ea635e054205d14c",
ip: "::",
listenAddr: "[::]:8000",
name: "Geth/v1.8.3-unstable/linux-amd64/go1.9.2",
ports: {
discovery: 8000,
listener: 8000
},
protocols: {
eth: {
config: {
byzantiumBlock: 4370000,
chainId: 1,
daoForkBlock: 1920000,
daoForkSupport: true,
eip150Block: 2463000,
eip150Hash: "0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0",
eip155Block: 2675000,
eip158Block: 2675000,
ethash: {},
homesteadBlock: 1150000
},
difficulty: 17179869184,
genesis: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
head: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
network: 1
}
}
}
添加节点
admin.addPeer('enode://8172f03e1fd2c1fe7ecf923d4de8c080bf0483520495c158d4e34c25aaf02acbbb82764b9abf5047fb146b8f61af853d59bc251d75e67a85038264e0be134104@127.0.0.1:8001')
true
查看新添加的节点
admin.peers
[{
caps: ["eth/62", "eth/63"],
id: "ea83ec3fcf70d31324c38ebbe36ade129cf4323285434cf6edc0e73837981af0c157cb4d72a22732696de15da6d3124f749dab40119d4115978d1490184fd0df",
name: "Geth/v1.7.2-stable-1db4ecdc/linux-amd64/go1.9",
network: {
inbound: false,
localAddress: "192.168.100.16:45652",
remoteAddress: "93.190.142.88:30303",
static: false,
trusted: false
},
protocols: {
eth: {
difficulty: 1.7170716931374346e+21,
head: "0xa3b233b624999e720973edc08a17db340b0bd62bc97e6e6bddd9f2009493c092",
version: 63
}
}
}]
判断是否是监听节点
net.listening
true
获取连接的节点数量
net.peerCount
4