Cosmetic renames to match the protocol naming conventions

This commit is contained in:
Zahary Karadjov 2019-11-25 19:08:09 +02:00 committed by zah
parent bc2b76f09a
commit a54fdc8073
3 changed files with 9 additions and 9 deletions

View File

@ -97,12 +97,12 @@ the definition of a RLPx protocol:
#### RLPx sub-protocols
The sub-protocols are defined with the `p2pProtocol` macro. It will accept
a 3-letter identifier for the protocol and the current protocol version:
a short identifier for the protocol and the current protocol version:
Here is how the [DevP2P wire protocol](https://github.com/ethereum/devp2p/blob/master/rlpx.md#p2p-capability) might look like:
``` nim
p2pProtocol p2p(version = 0):
p2pProtocol DevP2P(version = 0, rlpxName = "p2p"):
proc hello(peer: Peer,
version: uint,
clientId: string,

View File

@ -128,7 +128,7 @@ proc addHandshake*(mock: MockConf, msg: auto) =
msgInfo.protocol = mock.addProtocol(msgInfo.protocol)
let expectedMsg = ExpectedMsg(msg: msgInfo, response: reply(msg))
when msg is devp2p.hello:
when msg is DevP2P.hello:
devp2pHandshake = expectedMsg
else:
mock.handshakes.add expectedMsg

View File

@ -781,7 +781,7 @@ proc p2pProtocolBackendImpl*(protocol: P2PProtocol): Backend =
newLit(protocol.version),
protocol.peerInit, protocol.netInit)
p2pProtocol devp2p(version = 5, rlpxName = "p2p"):
p2pProtocol DevP2P(version = 5, rlpxName = "p2p"):
proc hello(peer: Peer,
version: uint,
clientId: string,
@ -857,7 +857,7 @@ proc disconnect*(peer: Peer, reason: DisconnectionReason, notifyOtherPeer = fals
peer.connectionState = Disconnected
removePeer(peer.network, peer)
proc validatePubKeyInHello(msg: devp2p.hello, pubKey: PublicKey): bool =
proc validatePubKeyInHello(msg: DevP2P.hello, pubKey: PublicKey): bool =
var pk: PublicKey
recoverPublicKey(msg.nodeId, pk) == EthKeysStatus.Success and pk == pubKey
@ -884,7 +884,7 @@ proc initPeerState*(peer: Peer, capabilities: openarray[Capability]) =
peer.lastReqId = 0
peer.initProtocolStates peer.dispatcher.activeProtocols
proc postHelloSteps(peer: Peer, h: devp2p.hello) {.async.} =
proc postHelloSteps(peer: Peer, h: DevP2P.hello) {.async.} =
initPeerState(peer, h.capabilities)
# Please note that the ordering of operations here is important!
@ -1017,13 +1017,13 @@ proc rlpxConnect*(node: EthereumNode, remote: Node): Future[Peer] {.async.} =
var response = await result.handshakeImpl(
sendHelloFut,
result.waitSingleMsg(devp2p.hello),
result.waitSingleMsg(DevP2P.hello),
10.seconds)
if not validatePubKeyInHello(response, remote.node.pubKey):
warn "Remote nodeId is not its public key" # XXX: Do we care?
trace "devp2p handshake completed", peer = remote,
trace "DevP2P handshake completed", peer = remote,
clientId = response.clientId
await postHelloSteps(result, response)
@ -1108,7 +1108,7 @@ proc rlpxAccept*(node: EthereumNode,
var response = await result.handshakeImpl(
sendHelloFut,
result.waitSingleMsg(devp2p.hello),
result.waitSingleMsg(DevP2P.hello),
10.seconds)
trace "Received Hello", version=response.version, id=response.clientId