本文章主上下两篇
本片为下篇:实践篇,主要描述如何获取以太坊所有节点信息(ip、port、nodeId、clientId)
因为以太坊创世块发展到如今,中间也有过很多次的迭代,所以通讯多少也有改变,这里不做一一说明,就以目前V62 V63 版本来做就可以了
根据上篇的理论知识,我们先理一下思路,如何去获取;
p2pVersion Specifies the implemented version of the P2P protocol. Now must be 1.
clientId Specifies the client software identity, as a human-readable string (e.g. "Ethereum(++)/1.0.0").
cap Specifies a peer capability name as an ASCII string, e.g. "eth" for the eth subprotocol.
capVersion Specifies a peer capability version as a positive integer.
listenPort specifies the port that the client is listening on (on the interface that the present connection traverses). If 0 it indicates the client is not listening.
nodeId is the unique identity of the node and specifies a 512-bit secp256k1 public key that identifies this node.
因为这也是小编工作的内容,所以代码不方便开源,建议去看以太坊源码的net 层的代码
The Ethereum devp2p and discv4 protocol Part II
原文:https://www.cnblogs.com/chenshouchang/p/10386094.html