From 833818e9c7f068388c1aebf29122a5cc59e53e3f Mon Sep 17 00:00:00 2001 From: Lorenzo Delgado Date: Wed, 30 Nov 2022 12:59:41 +0100 Subject: [PATCH] Make discv5 `protocol-id` configurable at compile time Co-authored-by: ksr --- eth/p2p/discoveryv5/encoding.nim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/eth/p2p/discoveryv5/encoding.nim b/eth/p2p/discoveryv5/encoding.nim index 0927ad5..ffa9d0f 100644 --- a/eth/p2p/discoveryv5/encoding.nim +++ b/eth/p2p/discoveryv5/encoding.nim @@ -31,12 +31,17 @@ declareCounter discovery_session_decrypt_failures, "Session decrypt failures" logScope: topics = "discv5" +# Support overriding the default discv5 protocol version and protocol id +# via compile time defines (e.g., '-d:discv5_protocol_id=d5waku') const - version: uint16 = 1 + discv5_protocol_version {.intdefine.} : uint16 = 1 + discv5_protocol_id {.strdefine.} = "discv5" + +const + version = discv5_protocol_version + protocolId = toBytes(discv5_protocol_id) idSignatureText = "discovery v5 identity proof" keyAgreementPrefix = "discovery v5 key agreement" - protocolIdStr = "discv5" - protocolId = toBytes(protocolIdStr) gcmNonceSize* = 12 idNonceSize* = 16 gcmTagSize* = 16