Allow devp2p sub-protocols to use version 0; Fix #119 (#121)

This commit is contained in:
zah 2019-11-19 07:16:35 +00:00 committed by Jacek Sieka
parent 680e52ec24
commit 7a39a50c27
1 changed files with 4 additions and 4 deletions

View File

@ -210,7 +210,7 @@ proc registerMsg(protocol: ProtocolInfo,
proc registerProtocol(protocol: ProtocolInfo) =
# TODO: This can be done at compile-time in the future
if protocol.version > 0:
if protocol.name != "p2p":
let pos = lowerBound(gProtocols, protocol)
gProtocols.insert(protocol, pos)
for i in 0 ..< gProtocols.len:
@ -588,7 +588,7 @@ proc p2pProtocolBackendImpl*(protocol: P2PProtocol): Backend =
ResponderWithId = bindSym "ResponderWithId"
ResponderWithoutId = bindSym "ResponderWithoutId"
isSubprotocol = protocol.version > 0
isSubprotocol = protocol.rlpxName != "p2p"
if protocol.rlpxName.len == 0: protocol.rlpxName = protocol.name
# By convention, all Ethereum protocol names were abbreviated to 3 letters,
@ -781,7 +781,7 @@ proc p2pProtocolBackendImpl*(protocol: P2PProtocol): Backend =
newLit(protocol.version),
protocol.peerInit, protocol.netInit)
p2pProtocol devp2p(version = 0, rlpxName = "p2p"):
p2pProtocol devp2p(version = 5, rlpxName = "p2p"):
proc hello(peer: Peer,
version: uint,
clientId: string,