From 81b861b34e7178339e127eb5cfe707401d5a2260 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Thu, 29 Jun 2023 15:28:25 +0200 Subject: [PATCH] avoid `ProveField` warning in `crypto.init` (#915) --- libp2p/crypto/crypto.nim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libp2p/crypto/crypto.nim b/libp2p/crypto/crypto.nim index 088322a0c..2accbdd5e 100644 --- a/libp2p/crypto/crypto.nim +++ b/libp2p/crypto/crypto.nim @@ -455,7 +455,8 @@ proc getBytes*(sig: Signature): seq[byte] = ## Return signature ``sig`` in binary form. result = sig.data -proc init*[T: PrivateKey|PublicKey](key: var T, data: openArray[byte]): bool = +template initImpl[T: PrivateKey|PublicKey]( + key: var T, data: openArray[byte]): bool = ## Initialize private key ``key`` from libp2p's protobuf serialized raw ## binary form. ## @@ -517,6 +518,14 @@ proc init*[T: PrivateKey|PublicKey](key: var T, data: openArray[byte]): bool = else: false +{.push warning[ProveField]:off.} # https://github.com/nim-lang/Nim/issues/22060 +proc init*(key: var PrivateKey, data: openArray[byte]): bool = + initImpl(key, data) + +proc init*(key: var PublicKey, data: openArray[byte]): bool = + initImpl(key, data) +{.pop.} + proc init*(sig: var Signature, data: openArray[byte]): bool = ## Initialize signature ``sig`` from raw binary form. ##