make it more Nim 1.4+ compatible (#742)

This commit is contained in:
Miran 2022-08-03 13:33:19 +02:00 committed by GitHub
parent 20c02a5f23
commit 2fbe82bf9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
81 changed files with 329 additions and 88 deletions

View File

@ -2,8 +2,6 @@
if dirExists("nimbledeps/pkgs"): if dirExists("nimbledeps/pkgs"):
switch("NimblePath", "nimbledeps/pkgs") switch("NimblePath", "nimbledeps/pkgs")
when (NimMajor, NimMinor) > (1, 2):
switch("hint", "XCannotRaiseY:off")
# begin Nimble config (version 1) # begin Nimble config (version 1)
when fileExists("nimble.paths"): when fileExists("nimble.paths"):
include "nimble.paths" include "nimble.paths"

View File

@ -16,7 +16,10 @@ runnableExamples:
# etc # etc
.build() .build()
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import import
options, tables, chronos, chronicles, sequtils, options, tables, chronos, chronicles, sequtils,

View File

@ -9,7 +9,10 @@
## This module implementes CID (Content IDentifier). ## This module implementes CID (Content IDentifier).
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import tables, hashes import tables, hashes
import multibase, multicodec, multihash, vbuffer, varint import multibase, multicodec, multihash, vbuffer, varint

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[options, tables, sequtils, sets] import std/[options, tables, sequtils, sets]
import pkg/[chronos, chronicles, metrics] import pkg/[chronos, chronicles, metrics]

View File

@ -15,7 +15,10 @@
# RFC @ https://tools.ietf.org/html/rfc7539 # RFC @ https://tools.ietf.org/html/rfc7539
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import bearssl/blockx import bearssl/blockx
from stew/assign2 import assign from stew/assign2 import assign

View File

@ -8,7 +8,10 @@
# those terms. # those terms.
## This module implements Public Key and Private Key interface for libp2p. ## 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 from strutils import split, strip, cmpIgnoreCase

View File

@ -15,7 +15,10 @@
# RFC @ https://tools.ietf.org/html/rfc7748 # 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 bearssl/[ec, rand, hash]
import stew/results import stew/results

View File

@ -14,7 +14,10 @@
## BearSSL library <https://bearssl.org/> ## BearSSL library <https://bearssl.org/>
## Copyright(C) 2018 Thomas Pornin <pornin@bolet.org>. ## Copyright(C) 2018 Thomas Pornin <pornin@bolet.org>.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import bearssl/[ec, rand, hash] import bearssl/[ec, rand, hash]
# We use `ncrutils` for constant-time hexadecimal encoding/decoding procedures. # We use `ncrutils` for constant-time hexadecimal encoding/decoding procedures.

View File

@ -11,7 +11,10 @@
## This code is a port of the public domain, "ref10" implementation of ed25519 ## This code is a port of the public domain, "ref10" implementation of ed25519
## from SUPERCOP. ## from SUPERCOP.
{.push raises: Defect.} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import bearssl/rand import bearssl/rand
import constants import constants

View File

@ -9,7 +9,10 @@
# https://tools.ietf.org/html/rfc5869 # https://tools.ietf.org/html/rfc5869
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import nimcrypto import nimcrypto
import bearssl/[kdf, rand, hash] import bearssl/[kdf, rand, hash]

View File

@ -9,7 +9,10 @@
## This module implements minimal ASN.1 encoding/decoding primitives. ## 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] import stew/[endians2, results, ctops]
export results export results

View File

@ -13,7 +13,11 @@
## BearSSL library <https://bearssl.org/> ## BearSSL library <https://bearssl.org/>
## Copyright(C) 2018 Thomas Pornin <pornin@bolet.org>. ## Copyright(C) 2018 Thomas Pornin <pornin@bolet.org>.
{.push raises: Defect.} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import bearssl/[rsa, rand, hash] import bearssl/[rsa, rand, hash]
import minasn1 import minasn1
import stew/[results, ctops] import stew/[results, ctops]

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import bearssl/rand import bearssl/rand
import import

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
## This module implementes API for `go-libp2p-daemon`. ## This module implementes API for `go-libp2p-daemon`.
import std/[os, osproc, strutils, tables, strtabs, sequtils] import std/[os, osproc, strutils, tables, strtabs, sequtils]

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
## This module implements Pool of StreamTransport. ## This module implements Pool of StreamTransport.
import chronos import chronos

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import chronos import chronos
import peerid, import peerid,

View File

@ -9,7 +9,10 @@
## This module implements MultiAddress. ## This module implements MultiAddress.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
{.push public.} {.push public.}
import pkg/chronos import pkg/chronos

View File

@ -13,7 +13,10 @@
## 1. base32z ## 1. base32z
## ##
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import tables import tables
import stew/[base32, base58, base64, results] import stew/[base32, base58, base64, results]

View File

@ -9,7 +9,10 @@
## This module implements MultiCodec. ## This module implements MultiCodec.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import tables, hashes import tables, hashes
import varint, vbuffer import varint, vbuffer

View File

@ -21,7 +21,10 @@
## 1. SKEIN ## 1. SKEIN
## 2. MURMUR ## 2. MURMUR
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import tables import tables
import nimcrypto/[sha, sha2, keccak, blake2, hash, utils] import nimcrypto/[sha, sha2, keccak, blake2, hash, utils]

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[strutils, sequtils] import std/[strutils, sequtils]
import chronos, chronicles, stew/byteutils import chronos, chronicles, stew/byteutils

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # 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 pkg/[chronos, nimcrypto/utils, chronicles, stew/byteutils]
import ../../stream/connection, import ../../stream/connection,

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[oids, strformat] import std/[oids, strformat]
import pkg/[chronos, chronicles, metrics, nimcrypto/utils] import pkg/[chronos, chronicles, metrics, nimcrypto/utils]
@ -84,7 +87,7 @@ proc open*(s: LPChannel) {.async, gcsafe.} =
await s.conn.close() await s.conn.close()
raise exc raise exc
method closed*(s: LPChannel): bool {.raises: [Defect].} = method closed*(s: LPChannel): bool =
s.closedLocal s.closedLocal
proc closeUnderlying(s: LPChannel): Future[void] {.async.} = proc closeUnderlying(s: LPChannel): Future[void] {.async.} =

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import tables, sequtils, oids import tables, sequtils, oids
import chronos, chronicles, stew/byteutils, metrics import chronos, chronicles, stew/byteutils, metrics

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import chronos, chronicles import chronos, chronicles
import ../protocols/protocol, import ../protocols/protocol,

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import sequtils, std/[tables] import sequtils, std/[tables]
import chronos, chronicles, metrics, stew/[endians2, byteutils, objects] import chronos, chronicles, metrics, stew/[endians2, byteutils, objects]

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import import
std/[streams, strutils, sets, sequtils], std/[streams, strutils, sets, sequtils],

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import import
std/[streams, strutils, tables], std/[streams, strutils, tables],

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[sugar, sets, sequtils, strutils] import std/[sugar, sets, sequtils, strutils]
import import

View File

@ -9,7 +9,10 @@
## This module implementes API for libp2p peer. ## This module implementes API for libp2p peer.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
{.push public.} {.push public.}
import import

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
{.push public.} {.push public.}
import std/[options, sequtils] import std/[options, sequtils]

View File

@ -22,7 +22,10 @@ runnableExamples:
peerStore[MoodBook][somePeerId] = "Happy" peerStore[MoodBook][somePeerId] = "Happy"
doAssert peerStore[MoodBook][somePeerId] == "Happy" doAssert peerStore[MoodBook][somePeerId] == "Happy"
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import import
std/[tables, sets, options, macros], std/[tables, sets, options, macros],

View File

@ -9,7 +9,10 @@
## This module implements minimal Google's ProtoBuf primitives. ## 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] import ../varint, ../utility, stew/[endians2, results]
export results, utility export results, utility

View File

@ -10,7 +10,10 @@
## `Identify <https://docs.libp2p.io/concepts/protocols/#identify>`_ and ## `Identify <https://docs.libp2p.io/concepts/protocols/#identify>`_ and
## `Push Identify <https://docs.libp2p.io/concepts/protocols/#identify-push>`_ implementation ## `Push Identify <https://docs.libp2p.io/concepts/protocols/#identify-push>`_ implementation
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[sequtils, options, strutils, sugar] import std/[sequtils, options, strutils, sugar]
import chronos, chronicles import chronos, chronicles

View File

@ -9,7 +9,10 @@
## `Ping <https://docs.libp2p.io/concepts/protocols/#ping>`_ protocol implementation ## `Ping <https://docs.libp2p.io/concepts/protocols/#ping>`_ protocol implementation
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import chronos, chronicles import chronos, chronicles
import bearssl/[rand, hash] import bearssl/[rand, hash]

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import chronos import chronos
import ../stream/connection import ../stream/connection

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[sequtils, sets, hashes, tables] import std/[sequtils, sets, hashes, tables]
import chronos, chronicles, metrics import chronos, chronicles, metrics

View File

@ -9,7 +9,10 @@
## Gossip based publishing ## Gossip based publishing
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[tables, sets, options, sequtils] import std/[tables, sets, options, sequtils]
import chronos, chronicles, metrics import chronos, chronicles, metrics

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[tables, sequtils, sets, algorithm] import std/[tables, sequtils, sets, algorithm]
import chronos, chronicles, metrics import chronos, chronicles, metrics

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[tables, sets, options] import std/[tables, sets, options]
import chronos, chronicles, metrics import chronos, chronicles, metrics
@ -101,7 +104,6 @@ proc disconnectPeer(g: GossipSub, peer: PubSubPeer) {.async.} =
except CatchableError as exc: # Never cancelled except CatchableError as exc: # Never cancelled
trace "Failed to close connection", peer, error = exc.name, msg = exc.msg trace "Failed to close connection", peer, error = exc.name, msg = exc.msg
{.push raises: [Defect].}
proc updateScores*(g: GossipSub) = # avoid async proc updateScores*(g: GossipSub) = # avoid async
## https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#the-score-function ## https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md#the-score-function

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import chronos import chronos
import std/[tables, sets] import std/[tables, sets]

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[sets, tables, options] import std/[sets, tables, options]
import rpc/[messages] import rpc/[messages]

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[tables, sets] import std/[tables, sets]
import ./pubsubpeer, ../../peerid import ./pubsubpeer, ../../peerid

View File

@ -13,7 +13,10 @@
## `publish<#publish.e%2CPubSub%2Cstring%2Cseq%5Bbyte%5D>`_ something on it, ## `publish<#publish.e%2CPubSub%2Cstring%2Cseq%5Bbyte%5D>`_ something on it,
## and eventually `unsubscribe<#unsubscribe%2CPubSub%2Cstring%2CTopicHandler>`_ from 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 std/[tables, sequtils, sets, strutils]
import chronos, chronicles, metrics import chronos, chronicles, metrics

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[sequtils, strutils, tables, hashes] import std/[sequtils, strutils, tables, hashes]
import chronos, chronicles, nimcrypto/sha2, metrics import chronos, chronicles, nimcrypto/sha2, metrics

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import hashes import hashes
import chronicles, metrics, stew/[byteutils, endians2] import chronicles, metrics, stew/[byteutils, endians2]

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import options, sequtils import options, sequtils
import "../../.."/[ import "../../.."/[

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import options import options
import stew/assign2 import stew/assign2
@ -17,7 +20,6 @@ import messages,
../../../utility, ../../../utility,
../../../protobuf/minprotobuf ../../../protobuf/minprotobuf
{.push raises: [Defect].}
logScope: logScope:
topics = "pubsubprotobuf" topics = "pubsubprotobuf"

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[tables] import std/[tables]

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import times, options import times, options

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import options, macros, sequtils import options, macros, sequtils
import stew/objects import stew/objects

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import chronos import chronos

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import options, sequtils, tables, sugar import options, sequtils, tables, sugar

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import sequtils, strutils import sequtils, strutils

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import options import options

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[oids, strformat] import std/[oids, strformat]
import chronos import chronos

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import chronos import chronos
import secure, ../../stream/connection import secure, ../../stream/connection

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[oids, strformat] import std/[oids, strformat]
import bearssl/rand import bearssl/rand

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[strformat] import std/[strformat]
import chronos, chronicles import chronos, chronicles

View File

@ -9,7 +9,10 @@
## This module implements Routing Records. ## This module implements Routing Records.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[sequtils, times] import std/[sequtils, times]
import pkg/stew/results import pkg/stew/results

View File

@ -9,7 +9,10 @@
## This module implements Signed Envelope. ## This module implements Signed Envelope.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/sugar import std/sugar
import pkg/stew/[results, byteutils] import pkg/stew/[results, byteutils]

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/strformat import std/strformat
import stew/byteutils import stew/byteutils
@ -108,7 +111,7 @@ method pushEof*(s: BufferStream) {.base, async.} =
finally: finally:
s.pushing = false s.pushing = false
method atEof*(s: BufferStream): bool {.raises: [Defect].} = method atEof*(s: BufferStream): bool =
s.isEof and s.readBuf.len == 0 s.isEof and s.readBuf.len == 0
method readOnce*(s: BufferStream, method readOnce*(s: BufferStream,

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[oids, strformat] import std/[oids, strformat]
import chronos, chronicles, metrics import chronos, chronicles, metrics

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[hashes, oids, strformat] import std/[hashes, oids, strformat]
import chronicles, chronos, metrics import chronicles, chronos, metrics

View File

@ -9,7 +9,10 @@
## Length Prefixed stream implementation ## Length Prefixed stream implementation
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/oids import std/oids
import stew/byteutils import stew/byteutils

View File

@ -1,4 +1,7 @@
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import stew/bitops2 import stew/bitops2

View File

@ -11,7 +11,10 @@
## transports, the connection manager, the upgrader and other ## transports, the connection manager, the upgrader and other
## parts to allow programs to use libp2p ## parts to allow programs to use libp2p
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[tables, import std/[tables,
options, options,

View File

@ -9,7 +9,10 @@
## TCP transport implementation ## TCP transport implementation
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[oids, sequtils] import std/[oids, sequtils]
import chronos, chronicles import chronos, chronicles

View File

@ -8,7 +8,10 @@
# those terms. # those terms.
## ##
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import sequtils import sequtils
import chronos, chronicles import chronos, chronicles

View File

@ -9,7 +9,10 @@
## WebSocket & WebSocket Secure transport implementation ## WebSocket & WebSocket Secure transport implementation
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[sequtils] import std/[sequtils]
import chronos, chronicles import chronos, chronicles

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[tables, sequtils] import std/[tables, sequtils]
import pkg/[chronos, chronicles, metrics] import pkg/[chronos, chronicles, metrics]

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import std/[options, sequtils, strutils] import std/[options, sequtils, strutils]
import pkg/[chronos, chronicles, metrics] import pkg/[chronos, chronicles, metrics]

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import stew/byteutils import stew/byteutils

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import sequtils import sequtils
import chronos, chronicles import chronos, chronicles

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import sequtils import sequtils
import chronos, chronicles import chronos, chronicles

View File

@ -16,7 +16,10 @@
## maximum size of encoded value is 9 octets (bytes). ## maximum size of encoded value is 9 octets (bytes).
## https://github.com/multiformats/unsigned-varint ## 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] import stew/[byteutils, leb128, results]
export leb128, results export leb128, results

View File

@ -9,7 +9,10 @@
## This module implements variable buffer. ## This module implements variable buffer.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import varint, strutils import varint, strutils

View File

@ -7,7 +7,10 @@
# This file may not be copied, modified, or distributed except according to # This file may not be copied, modified, or distributed except according to
# those terms. # those terms.
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
## This module implements wire network connection procedures. ## This module implements wire network connection procedures.
import chronos, stew/endians2 import chronos, stew/endians2

View File

@ -1,4 +1,7 @@
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import chronos import chronos
@ -13,7 +16,6 @@ import ../libp2p/protocols/secure/secure
import ./asyncunit import ./asyncunit
export asyncunit export asyncunit
{.push raises: [Defect].}
const const
StreamTransportTrackerName = "stream.transport" StreamTransportTrackerName = "stream.transport"

View File

@ -11,7 +11,10 @@ import ../libp2p/errors,
../libp2p/upgrademngrs/upgrade ../libp2p/upgrademngrs/upgrade
{.push raises: [Defect].} when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import ./helpers import ./helpers
@ -56,7 +59,7 @@ method readOnce*(s: TestSelectStream,
method write*(s: TestSelectStream, msg: seq[byte]) {.async, gcsafe.} = discard 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.isClosed = true
s.isEof = true s.isEof = true

View File

@ -39,7 +39,12 @@ const
type type
TestProto = ref object of LPProtocol 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.} = proc handle(conn: Connection, proto: string) {.async, gcsafe.} =
let msg = string.fromBytes(await conn.readLp(1024)) let msg = string.fromBytes(await conn.readLp(1024))
check "Hello!" == msg check "Hello!" == msg
@ -49,6 +54,9 @@ method init(p: TestProto) {.gcsafe, raises: [Defect].} =
p.codec = TestCodec p.codec = TestCodec
p.handler = handle p.handler = handle
{.pop.}
proc createSwitch(ma: MultiAddress; outgoing: bool, secio: bool = false): (Switch, PeerInfo) = proc createSwitch(ma: MultiAddress; outgoing: bool, secio: bool = false): (Switch, PeerInfo) =
var var
privateKey = PrivateKey.random(ECDSA, rng[]).get() privateKey = PrivateKey.random(ECDSA, rng[]).get()