diff --git a/config.nims b/config.nims
index 23bf10e37..0a5c80dbc 100644
--- a/config.nims
+++ b/config.nims
@@ -2,8 +2,6 @@
if dirExists("nimbledeps/pkgs"):
switch("NimblePath", "nimbledeps/pkgs")
-when (NimMajor, NimMinor) > (1, 2):
- switch("hint", "XCannotRaiseY:off")
# begin Nimble config (version 1)
when fileExists("nimble.paths"):
include "nimble.paths"
diff --git a/libp2p/builders.nim b/libp2p/builders.nim
index 30d8a05db..b459a9a9c 100644
--- a/libp2p/builders.nim
+++ b/libp2p/builders.nim
@@ -16,7 +16,10 @@ runnableExamples:
# etc
.build()
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import
options, tables, chronos, chronicles, sequtils,
diff --git a/libp2p/cid.nim b/libp2p/cid.nim
index f12c4d814..1f18f8201 100644
--- a/libp2p/cid.nim
+++ b/libp2p/cid.nim
@@ -9,7 +9,10 @@
## This module implementes CID (Content IDentifier).
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import tables, hashes
import multibase, multicodec, multihash, vbuffer, varint
diff --git a/libp2p/connmanager.nim b/libp2p/connmanager.nim
index e3cb2e8e9..e64947e51 100644
--- a/libp2p/connmanager.nim
+++ b/libp2p/connmanager.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[options, tables, sequtils, sets]
import pkg/[chronos, chronicles, metrics]
diff --git a/libp2p/crypto/chacha20poly1305.nim b/libp2p/crypto/chacha20poly1305.nim
index c3eeca776..8482897d8 100644
--- a/libp2p/crypto/chacha20poly1305.nim
+++ b/libp2p/crypto/chacha20poly1305.nim
@@ -15,7 +15,10 @@
# RFC @ https://tools.ietf.org/html/rfc7539
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import bearssl/blockx
from stew/assign2 import assign
diff --git a/libp2p/crypto/crypto.nim b/libp2p/crypto/crypto.nim
index 99bf5849b..1ccf8386f 100644
--- a/libp2p/crypto/crypto.nim
+++ b/libp2p/crypto/crypto.nim
@@ -8,7 +8,10 @@
# those terms.
## This module implements Public Key and Private Key interface for libp2p.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
from strutils import split, strip, cmpIgnoreCase
diff --git a/libp2p/crypto/curve25519.nim b/libp2p/crypto/curve25519.nim
index ad14ec6f8..d4b476bc7 100644
--- a/libp2p/crypto/curve25519.nim
+++ b/libp2p/crypto/curve25519.nim
@@ -15,7 +15,10 @@
# RFC @ https://tools.ietf.org/html/rfc7748
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import bearssl/[ec, rand, hash]
import stew/results
diff --git a/libp2p/crypto/ecnist.nim b/libp2p/crypto/ecnist.nim
index e6874613a..51786f3b1 100644
--- a/libp2p/crypto/ecnist.nim
+++ b/libp2p/crypto/ecnist.nim
@@ -14,7 +14,10 @@
## BearSSL library
## Copyright(C) 2018 Thomas Pornin .
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import bearssl/[ec, rand, hash]
# We use `ncrutils` for constant-time hexadecimal encoding/decoding procedures.
diff --git a/libp2p/crypto/ed25519/ed25519.nim b/libp2p/crypto/ed25519/ed25519.nim
index e6e199694..c906113a9 100644
--- a/libp2p/crypto/ed25519/ed25519.nim
+++ b/libp2p/crypto/ed25519/ed25519.nim
@@ -11,7 +11,10 @@
## This code is a port of the public domain, "ref10" implementation of ed25519
## from SUPERCOP.
-{.push raises: Defect.}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import bearssl/rand
import constants
diff --git a/libp2p/crypto/hkdf.nim b/libp2p/crypto/hkdf.nim
index 4159867c5..88ad17a8f 100644
--- a/libp2p/crypto/hkdf.nim
+++ b/libp2p/crypto/hkdf.nim
@@ -9,7 +9,10 @@
# https://tools.ietf.org/html/rfc5869
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import nimcrypto
import bearssl/[kdf, rand, hash]
diff --git a/libp2p/crypto/minasn1.nim b/libp2p/crypto/minasn1.nim
index c23b0e35d..cb30b662d 100644
--- a/libp2p/crypto/minasn1.nim
+++ b/libp2p/crypto/minasn1.nim
@@ -9,7 +9,10 @@
## This module implements minimal ASN.1 encoding/decoding primitives.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import stew/[endians2, results, ctops]
export results
diff --git a/libp2p/crypto/rsa.nim b/libp2p/crypto/rsa.nim
index 2b95a4452..5fe82ee06 100644
--- a/libp2p/crypto/rsa.nim
+++ b/libp2p/crypto/rsa.nim
@@ -13,7 +13,11 @@
## BearSSL library
## Copyright(C) 2018 Thomas Pornin .
-{.push raises: Defect.}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
+
import bearssl/[rsa, rand, hash]
import minasn1
import stew/[results, ctops]
diff --git a/libp2p/crypto/secp.nim b/libp2p/crypto/secp.nim
index bff6b518a..20daa13ef 100644
--- a/libp2p/crypto/secp.nim
+++ b/libp2p/crypto/secp.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import bearssl/rand
import
diff --git a/libp2p/daemon/daemonapi.nim b/libp2p/daemon/daemonapi.nim
index 2c330db24..4e802c434 100644
--- a/libp2p/daemon/daemonapi.nim
+++ b/libp2p/daemon/daemonapi.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
## This module implementes API for `go-libp2p-daemon`.
import std/[os, osproc, strutils, tables, strtabs, sequtils]
diff --git a/libp2p/daemon/transpool.nim b/libp2p/daemon/transpool.nim
index 381f82744..c1c07c16d 100644
--- a/libp2p/daemon/transpool.nim
+++ b/libp2p/daemon/transpool.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
## This module implements Pool of StreamTransport.
import chronos
diff --git a/libp2p/dial.nim b/libp2p/dial.nim
index 9f16c89ce..46843e56f 100644
--- a/libp2p/dial.nim
+++ b/libp2p/dial.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import chronos
import peerid,
diff --git a/libp2p/multiaddress.nim b/libp2p/multiaddress.nim
index 4405973fe..948548814 100644
--- a/libp2p/multiaddress.nim
+++ b/libp2p/multiaddress.nim
@@ -9,7 +9,10 @@
## This module implements MultiAddress.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
{.push public.}
import pkg/chronos
diff --git a/libp2p/multibase.nim b/libp2p/multibase.nim
index 19ca75f87..61430f3b5 100644
--- a/libp2p/multibase.nim
+++ b/libp2p/multibase.nim
@@ -13,7 +13,10 @@
## 1. base32z
##
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import tables
import stew/[base32, base58, base64, results]
diff --git a/libp2p/multicodec.nim b/libp2p/multicodec.nim
index 6abfbcae0..0cfc4c558 100644
--- a/libp2p/multicodec.nim
+++ b/libp2p/multicodec.nim
@@ -9,7 +9,10 @@
## This module implements MultiCodec.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import tables, hashes
import varint, vbuffer
diff --git a/libp2p/multihash.nim b/libp2p/multihash.nim
index f449bbd3a..f991b02ba 100644
--- a/libp2p/multihash.nim
+++ b/libp2p/multihash.nim
@@ -21,7 +21,10 @@
## 1. SKEIN
## 2. MURMUR
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import tables
import nimcrypto/[sha, sha2, keccak, blake2, hash, utils]
diff --git a/libp2p/multistream.nim b/libp2p/multistream.nim
index c44f9564d..e2797a6a3 100644
--- a/libp2p/multistream.nim
+++ b/libp2p/multistream.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[strutils, sequtils]
import chronos, chronicles, stew/byteutils
diff --git a/libp2p/muxers/mplex/coder.nim b/libp2p/muxers/mplex/coder.nim
index e1ba5bf77..f2cce3fce 100644
--- a/libp2p/muxers/mplex/coder.nim
+++ b/libp2p/muxers/mplex/coder.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import pkg/[chronos, nimcrypto/utils, chronicles, stew/byteutils]
import ../../stream/connection,
diff --git a/libp2p/muxers/mplex/lpchannel.nim b/libp2p/muxers/mplex/lpchannel.nim
index a15191501..54d0da5da 100644
--- a/libp2p/muxers/mplex/lpchannel.nim
+++ b/libp2p/muxers/mplex/lpchannel.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[oids, strformat]
import pkg/[chronos, chronicles, metrics, nimcrypto/utils]
@@ -84,7 +87,7 @@ proc open*(s: LPChannel) {.async, gcsafe.} =
await s.conn.close()
raise exc
-method closed*(s: LPChannel): bool {.raises: [Defect].} =
+method closed*(s: LPChannel): bool =
s.closedLocal
proc closeUnderlying(s: LPChannel): Future[void] {.async.} =
diff --git a/libp2p/muxers/mplex/mplex.nim b/libp2p/muxers/mplex/mplex.nim
index e2d54a16b..90838120d 100644
--- a/libp2p/muxers/mplex/mplex.nim
+++ b/libp2p/muxers/mplex/mplex.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import tables, sequtils, oids
import chronos, chronicles, stew/byteutils, metrics
diff --git a/libp2p/muxers/muxer.nim b/libp2p/muxers/muxer.nim
index eda79c019..69e57e131 100644
--- a/libp2p/muxers/muxer.nim
+++ b/libp2p/muxers/muxer.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import chronos, chronicles
import ../protocols/protocol,
diff --git a/libp2p/muxers/yamux/yamux.nim b/libp2p/muxers/yamux/yamux.nim
index 02e96f7ce..83deb1009 100644
--- a/libp2p/muxers/yamux/yamux.nim
+++ b/libp2p/muxers/yamux/yamux.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import sequtils, std/[tables]
import chronos, chronicles, metrics, stew/[endians2, byteutils, objects]
diff --git a/libp2p/nameresolving/dnsresolver.nim b/libp2p/nameresolving/dnsresolver.nim
index 2bda23c72..51be45624 100644
--- a/libp2p/nameresolving/dnsresolver.nim
+++ b/libp2p/nameresolving/dnsresolver.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import
std/[streams, strutils, sets, sequtils],
diff --git a/libp2p/nameresolving/mockresolver.nim b/libp2p/nameresolving/mockresolver.nim
index e1d84488e..4d9a0617b 100644
--- a/libp2p/nameresolving/mockresolver.nim
+++ b/libp2p/nameresolving/mockresolver.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import
std/[streams, strutils, tables],
diff --git a/libp2p/nameresolving/nameresolver.nim b/libp2p/nameresolving/nameresolver.nim
index ad87af13e..0fdd6a029 100644
--- a/libp2p/nameresolving/nameresolver.nim
+++ b/libp2p/nameresolving/nameresolver.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[sugar, sets, sequtils, strutils]
import
diff --git a/libp2p/peerid.nim b/libp2p/peerid.nim
index efc43cfc4..dc7a4aee0 100644
--- a/libp2p/peerid.nim
+++ b/libp2p/peerid.nim
@@ -9,7 +9,10 @@
## This module implementes API for libp2p peer.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
{.push public.}
import
diff --git a/libp2p/peerinfo.nim b/libp2p/peerinfo.nim
index 2834211fd..59fbe74e7 100644
--- a/libp2p/peerinfo.nim
+++ b/libp2p/peerinfo.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
{.push public.}
import std/[options, sequtils]
diff --git a/libp2p/peerstore.nim b/libp2p/peerstore.nim
index efe38a6a9..88f2ec400 100644
--- a/libp2p/peerstore.nim
+++ b/libp2p/peerstore.nim
@@ -22,7 +22,10 @@ runnableExamples:
peerStore[MoodBook][somePeerId] = "Happy"
doAssert peerStore[MoodBook][somePeerId] == "Happy"
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import
std/[tables, sets, options, macros],
diff --git a/libp2p/protobuf/minprotobuf.nim b/libp2p/protobuf/minprotobuf.nim
index a7144e21d..e1e36bd61 100644
--- a/libp2p/protobuf/minprotobuf.nim
+++ b/libp2p/protobuf/minprotobuf.nim
@@ -9,7 +9,10 @@
## This module implements minimal Google's ProtoBuf primitives.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import ../varint, ../utility, stew/[endians2, results]
export results, utility
diff --git a/libp2p/protocols/identify.nim b/libp2p/protocols/identify.nim
index 9fce0e150..975126ff8 100644
--- a/libp2p/protocols/identify.nim
+++ b/libp2p/protocols/identify.nim
@@ -10,7 +10,10 @@
## `Identify `_ and
## `Push Identify `_ implementation
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[sequtils, options, strutils, sugar]
import chronos, chronicles
diff --git a/libp2p/protocols/ping.nim b/libp2p/protocols/ping.nim
index 648a60d7c..9c31c8935 100644
--- a/libp2p/protocols/ping.nim
+++ b/libp2p/protocols/ping.nim
@@ -9,7 +9,10 @@
## `Ping `_ protocol implementation
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import chronos, chronicles
import bearssl/[rand, hash]
diff --git a/libp2p/protocols/protocol.nim b/libp2p/protocols/protocol.nim
index adafe89d4..ee3c39a62 100644
--- a/libp2p/protocols/protocol.nim
+++ b/libp2p/protocols/protocol.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import chronos
import ../stream/connection
diff --git a/libp2p/protocols/pubsub/floodsub.nim b/libp2p/protocols/pubsub/floodsub.nim
index 56c08094f..0bbf09399 100644
--- a/libp2p/protocols/pubsub/floodsub.nim
+++ b/libp2p/protocols/pubsub/floodsub.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[sequtils, sets, hashes, tables]
import chronos, chronicles, metrics
diff --git a/libp2p/protocols/pubsub/gossipsub.nim b/libp2p/protocols/pubsub/gossipsub.nim
index 72beab51d..9d816795e 100644
--- a/libp2p/protocols/pubsub/gossipsub.nim
+++ b/libp2p/protocols/pubsub/gossipsub.nim
@@ -9,7 +9,10 @@
## Gossip based publishing
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[tables, sets, options, sequtils]
import chronos, chronicles, metrics
diff --git a/libp2p/protocols/pubsub/gossipsub/behavior.nim b/libp2p/protocols/pubsub/gossipsub/behavior.nim
index 5351e464e..b3b1f4cad 100644
--- a/libp2p/protocols/pubsub/gossipsub/behavior.nim
+++ b/libp2p/protocols/pubsub/gossipsub/behavior.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[tables, sequtils, sets, algorithm]
import chronos, chronicles, metrics
diff --git a/libp2p/protocols/pubsub/gossipsub/scoring.nim b/libp2p/protocols/pubsub/gossipsub/scoring.nim
index 28ae245a5..801134d2f 100644
--- a/libp2p/protocols/pubsub/gossipsub/scoring.nim
+++ b/libp2p/protocols/pubsub/gossipsub/scoring.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[tables, sets, options]
import chronos, chronicles, metrics
@@ -101,7 +104,6 @@ proc disconnectPeer(g: GossipSub, peer: PubSubPeer) {.async.} =
except CatchableError as exc: # Never cancelled
trace "Failed to close connection", peer, error = exc.name, msg = exc.msg
-{.push raises: [Defect].}
proc updateScores*(g: GossipSub) = # avoid async
## https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#the-score-function
diff --git a/libp2p/protocols/pubsub/gossipsub/types.nim b/libp2p/protocols/pubsub/gossipsub/types.nim
index 89107a7ee..5142aef9c 100644
--- a/libp2p/protocols/pubsub/gossipsub/types.nim
+++ b/libp2p/protocols/pubsub/gossipsub/types.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import chronos
import std/[tables, sets]
diff --git a/libp2p/protocols/pubsub/mcache.nim b/libp2p/protocols/pubsub/mcache.nim
index ef7c8d03b..edb5fe4ad 100644
--- a/libp2p/protocols/pubsub/mcache.nim
+++ b/libp2p/protocols/pubsub/mcache.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[sets, tables, options]
import rpc/[messages]
diff --git a/libp2p/protocols/pubsub/peertable.nim b/libp2p/protocols/pubsub/peertable.nim
index c8eb86c2a..22034010b 100644
--- a/libp2p/protocols/pubsub/peertable.nim
+++ b/libp2p/protocols/pubsub/peertable.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[tables, sets]
import ./pubsubpeer, ../../peerid
diff --git a/libp2p/protocols/pubsub/pubsub.nim b/libp2p/protocols/pubsub/pubsub.nim
index 75ab36370..823d792cb 100644
--- a/libp2p/protocols/pubsub/pubsub.nim
+++ b/libp2p/protocols/pubsub/pubsub.nim
@@ -13,7 +13,10 @@
## `publish<#publish.e%2CPubSub%2Cstring%2Cseq%5Bbyte%5D>`_ something on it,
## and eventually `unsubscribe<#unsubscribe%2CPubSub%2Cstring%2CTopicHandler>`_ from it.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[tables, sequtils, sets, strutils]
import chronos, chronicles, metrics
diff --git a/libp2p/protocols/pubsub/pubsubpeer.nim b/libp2p/protocols/pubsub/pubsubpeer.nim
index f2dd144f4..89f5733da 100644
--- a/libp2p/protocols/pubsub/pubsubpeer.nim
+++ b/libp2p/protocols/pubsub/pubsubpeer.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[sequtils, strutils, tables, hashes]
import chronos, chronicles, nimcrypto/sha2, metrics
diff --git a/libp2p/protocols/pubsub/rpc/message.nim b/libp2p/protocols/pubsub/rpc/message.nim
index 8303a71b9..e0c322bc7 100644
--- a/libp2p/protocols/pubsub/rpc/message.nim
+++ b/libp2p/protocols/pubsub/rpc/message.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import hashes
import chronicles, metrics, stew/[byteutils, endians2]
diff --git a/libp2p/protocols/pubsub/rpc/messages.nim b/libp2p/protocols/pubsub/rpc/messages.nim
index e6a906c92..b12f45316 100644
--- a/libp2p/protocols/pubsub/rpc/messages.nim
+++ b/libp2p/protocols/pubsub/rpc/messages.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import options, sequtils
import "../../.."/[
diff --git a/libp2p/protocols/pubsub/rpc/protobuf.nim b/libp2p/protocols/pubsub/rpc/protobuf.nim
index a32af070a..1b4cd2268 100644
--- a/libp2p/protocols/pubsub/rpc/protobuf.nim
+++ b/libp2p/protocols/pubsub/rpc/protobuf.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import options
import stew/assign2
@@ -17,7 +20,6 @@ import messages,
../../../utility,
../../../protobuf/minprotobuf
-{.push raises: [Defect].}
logScope:
topics = "pubsubprotobuf"
diff --git a/libp2p/protocols/pubsub/timedcache.nim b/libp2p/protocols/pubsub/timedcache.nim
index 7cdf26b70..83bb08c63 100644
--- a/libp2p/protocols/pubsub/timedcache.nim
+++ b/libp2p/protocols/pubsub/timedcache.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[tables]
diff --git a/libp2p/protocols/relay/client.nim b/libp2p/protocols/relay/client.nim
index 87811a89b..8f03881ae 100644
--- a/libp2p/protocols/relay/client.nim
+++ b/libp2p/protocols/relay/client.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import times, options
diff --git a/libp2p/protocols/relay/messages.nim b/libp2p/protocols/relay/messages.nim
index af55c8874..62e2aaa0f 100644
--- a/libp2p/protocols/relay/messages.nim
+++ b/libp2p/protocols/relay/messages.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import options, macros, sequtils
import stew/objects
diff --git a/libp2p/protocols/relay/rconn.nim b/libp2p/protocols/relay/rconn.nim
index c407cd535..44dbb1445 100644
--- a/libp2p/protocols/relay/rconn.nim
+++ b/libp2p/protocols/relay/rconn.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import chronos
diff --git a/libp2p/protocols/relay/relay.nim b/libp2p/protocols/relay/relay.nim
index 394e4bde8..10288eb34 100644
--- a/libp2p/protocols/relay/relay.nim
+++ b/libp2p/protocols/relay/relay.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import options, sequtils, tables, sugar
diff --git a/libp2p/protocols/relay/rtransport.nim b/libp2p/protocols/relay/rtransport.nim
index 15edd4f7e..d84f43355 100644
--- a/libp2p/protocols/relay/rtransport.nim
+++ b/libp2p/protocols/relay/rtransport.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import sequtils, strutils
diff --git a/libp2p/protocols/relay/utils.nim b/libp2p/protocols/relay/utils.nim
index 246676203..efa9744ba 100644
--- a/libp2p/protocols/relay/utils.nim
+++ b/libp2p/protocols/relay/utils.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import options
diff --git a/libp2p/protocols/secure/noise.nim b/libp2p/protocols/secure/noise.nim
index 4051f09c8..6e613ea42 100644
--- a/libp2p/protocols/secure/noise.nim
+++ b/libp2p/protocols/secure/noise.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[oids, strformat]
import chronos
diff --git a/libp2p/protocols/secure/plaintext.nim b/libp2p/protocols/secure/plaintext.nim
index c7e44a5ee..151c7e6b0 100644
--- a/libp2p/protocols/secure/plaintext.nim
+++ b/libp2p/protocols/secure/plaintext.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import chronos
import secure, ../../stream/connection
diff --git a/libp2p/protocols/secure/secio.nim b/libp2p/protocols/secure/secio.nim
index f963a795d..46a05c71c 100644
--- a/libp2p/protocols/secure/secio.nim
+++ b/libp2p/protocols/secure/secio.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[oids, strformat]
import bearssl/rand
diff --git a/libp2p/protocols/secure/secure.nim b/libp2p/protocols/secure/secure.nim
index 58bfc9f12..f841a5d04 100644
--- a/libp2p/protocols/secure/secure.nim
+++ b/libp2p/protocols/secure/secure.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[strformat]
import chronos, chronicles
diff --git a/libp2p/routing_record.nim b/libp2p/routing_record.nim
index 10b584864..cde43c33b 100644
--- a/libp2p/routing_record.nim
+++ b/libp2p/routing_record.nim
@@ -9,7 +9,10 @@
## This module implements Routing Records.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[sequtils, times]
import pkg/stew/results
diff --git a/libp2p/signed_envelope.nim b/libp2p/signed_envelope.nim
index ac680d2c7..7d4e3dec1 100644
--- a/libp2p/signed_envelope.nim
+++ b/libp2p/signed_envelope.nim
@@ -9,7 +9,10 @@
## This module implements Signed Envelope.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/sugar
import pkg/stew/[results, byteutils]
diff --git a/libp2p/stream/bufferstream.nim b/libp2p/stream/bufferstream.nim
index cc3471a49..6eb83ed0c 100644
--- a/libp2p/stream/bufferstream.nim
+++ b/libp2p/stream/bufferstream.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/strformat
import stew/byteutils
@@ -108,7 +111,7 @@ method pushEof*(s: BufferStream) {.base, async.} =
finally:
s.pushing = false
-method atEof*(s: BufferStream): bool {.raises: [Defect].} =
+method atEof*(s: BufferStream): bool =
s.isEof and s.readBuf.len == 0
method readOnce*(s: BufferStream,
diff --git a/libp2p/stream/chronosstream.nim b/libp2p/stream/chronosstream.nim
index 5ada270e9..2b676d468 100644
--- a/libp2p/stream/chronosstream.nim
+++ b/libp2p/stream/chronosstream.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[oids, strformat]
import chronos, chronicles, metrics
diff --git a/libp2p/stream/connection.nim b/libp2p/stream/connection.nim
index 5216990c9..43f58af66 100644
--- a/libp2p/stream/connection.nim
+++ b/libp2p/stream/connection.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[hashes, oids, strformat]
import chronicles, chronos, metrics
diff --git a/libp2p/stream/lpstream.nim b/libp2p/stream/lpstream.nim
index ec3a7b28d..6857da3f4 100644
--- a/libp2p/stream/lpstream.nim
+++ b/libp2p/stream/lpstream.nim
@@ -9,7 +9,10 @@
## Length Prefixed stream implementation
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/oids
import stew/byteutils
diff --git a/libp2p/stream/streamseq.nim b/libp2p/stream/streamseq.nim
index 13ac06071..f91b9bdf7 100644
--- a/libp2p/stream/streamseq.nim
+++ b/libp2p/stream/streamseq.nim
@@ -1,4 +1,7 @@
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import stew/bitops2
diff --git a/libp2p/switch.nim b/libp2p/switch.nim
index cfa7dc82d..6a6cf6979 100644
--- a/libp2p/switch.nim
+++ b/libp2p/switch.nim
@@ -11,7 +11,10 @@
## transports, the connection manager, the upgrader and other
## parts to allow programs to use libp2p
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[tables,
options,
diff --git a/libp2p/transports/tcptransport.nim b/libp2p/transports/tcptransport.nim
index 589854c51..24f63f6af 100644
--- a/libp2p/transports/tcptransport.nim
+++ b/libp2p/transports/tcptransport.nim
@@ -9,7 +9,10 @@
## TCP transport implementation
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[oids, sequtils]
import chronos, chronicles
diff --git a/libp2p/transports/transport.nim b/libp2p/transports/transport.nim
index d377a961d..951f8bf83 100644
--- a/libp2p/transports/transport.nim
+++ b/libp2p/transports/transport.nim
@@ -8,7 +8,10 @@
# those terms.
##
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import sequtils
import chronos, chronicles
diff --git a/libp2p/transports/wstransport.nim b/libp2p/transports/wstransport.nim
index 15fb5be83..50eb7c333 100644
--- a/libp2p/transports/wstransport.nim
+++ b/libp2p/transports/wstransport.nim
@@ -9,7 +9,10 @@
## WebSocket & WebSocket Secure transport implementation
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[sequtils]
import chronos, chronicles
diff --git a/libp2p/upgrademngrs/muxedupgrade.nim b/libp2p/upgrademngrs/muxedupgrade.nim
index 867d060d5..f60d0c159 100644
--- a/libp2p/upgrademngrs/muxedupgrade.nim
+++ b/libp2p/upgrademngrs/muxedupgrade.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[tables, sequtils]
import pkg/[chronos, chronicles, metrics]
diff --git a/libp2p/upgrademngrs/upgrade.nim b/libp2p/upgrademngrs/upgrade.nim
index 758cc9ae3..781a074bc 100644
--- a/libp2p/upgrademngrs/upgrade.nim
+++ b/libp2p/upgrademngrs/upgrade.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import std/[options, sequtils, strutils]
import pkg/[chronos, chronicles, metrics]
diff --git a/libp2p/utility.nim b/libp2p/utility.nim
index 8cb7a7b22..dd499b5bb 100644
--- a/libp2p/utility.nim
+++ b/libp2p/utility.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import stew/byteutils
diff --git a/libp2p/utils/heartbeat.nim b/libp2p/utils/heartbeat.nim
index 3fad818a0..6756b1625 100644
--- a/libp2p/utils/heartbeat.nim
+++ b/libp2p/utils/heartbeat.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import sequtils
import chronos, chronicles
diff --git a/libp2p/utils/semaphore.nim b/libp2p/utils/semaphore.nim
index 4fc114ddf..12f4a4daf 100644
--- a/libp2p/utils/semaphore.nim
+++ b/libp2p/utils/semaphore.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import sequtils
import chronos, chronicles
diff --git a/libp2p/varint.nim b/libp2p/varint.nim
index 328ab51de..e881a317a 100644
--- a/libp2p/varint.nim
+++ b/libp2p/varint.nim
@@ -16,7 +16,10 @@
## maximum size of encoded value is 9 octets (bytes).
## https://github.com/multiformats/unsigned-varint
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import stew/[byteutils, leb128, results]
export leb128, results
diff --git a/libp2p/vbuffer.nim b/libp2p/vbuffer.nim
index 3f318e0f7..7a834ad23 100644
--- a/libp2p/vbuffer.nim
+++ b/libp2p/vbuffer.nim
@@ -9,7 +9,10 @@
## This module implements variable buffer.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import varint, strutils
diff --git a/libp2p/wire.nim b/libp2p/wire.nim
index f8f9d18e4..61c0010af 100644
--- a/libp2p/wire.nim
+++ b/libp2p/wire.nim
@@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to
# those terms.
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
## This module implements wire network connection procedures.
import chronos, stew/endians2
diff --git a/tests/helpers.nim b/tests/helpers.nim
index 7be83da8f..b82011f7c 100644
--- a/tests/helpers.nim
+++ b/tests/helpers.nim
@@ -1,4 +1,7 @@
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import chronos
@@ -13,7 +16,6 @@ import ../libp2p/protocols/secure/secure
import ./asyncunit
export asyncunit
-{.push raises: [Defect].}
const
StreamTransportTrackerName = "stream.transport"
diff --git a/tests/testmultistream.nim b/tests/testmultistream.nim
index 6b07fcc72..6bdf1aa40 100644
--- a/tests/testmultistream.nim
+++ b/tests/testmultistream.nim
@@ -11,7 +11,10 @@ import ../libp2p/errors,
../libp2p/upgrademngrs/upgrade
-{.push raises: [Defect].}
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
import ./helpers
@@ -56,7 +59,7 @@ method readOnce*(s: TestSelectStream,
method write*(s: TestSelectStream, msg: seq[byte]) {.async, gcsafe.} = discard
-method close(s: TestSelectStream) {.async, gcsafe, raises: [Defect].} =
+method close(s: TestSelectStream) {.async, gcsafe.} =
s.isClosed = true
s.isEof = true
diff --git a/tests/testnoise.nim b/tests/testnoise.nim
index 156d5da69..eabe56b58 100644
--- a/tests/testnoise.nim
+++ b/tests/testnoise.nim
@@ -39,7 +39,12 @@ const
type
TestProto = ref object of LPProtocol
-method init(p: TestProto) {.gcsafe, raises: [Defect].} =
+when (NimMajor, NimMinor) < (1, 4):
+ {.push raises: [Defect].}
+else:
+ {.push raises: [].}
+
+method init(p: TestProto) {.gcsafe.} =
proc handle(conn: Connection, proto: string) {.async, gcsafe.} =
let msg = string.fromBytes(await conn.readLp(1024))
check "Hello!" == msg
@@ -49,6 +54,9 @@ method init(p: TestProto) {.gcsafe, raises: [Defect].} =
p.codec = TestCodec
p.handler = handle
+{.pop.}
+
+
proc createSwitch(ma: MultiAddress; outgoing: bool, secio: bool = false): (Switch, PeerInfo) =
var
privateKey = PrivateKey.random(ECDSA, rng[]).get()