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"):
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"

View File

@ -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,

View File

@ -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

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -14,7 +14,10 @@
## BearSSL library <https://bearssl.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]
# 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
## from SUPERCOP.
{.push raises: Defect.}
when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].}
else:
{.push raises: [].}
import bearssl/rand
import constants

View File

@ -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]

View File

@ -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

View File

@ -13,7 +13,11 @@
## BearSSL library <https://bearssl.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 minasn1
import stew/[results, ctops]

View File

@ -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

View File

@ -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]

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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]

View File

@ -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

View File

@ -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]

View File

@ -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

View File

@ -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,

View File

@ -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.} =

View File

@ -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

View File

@ -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,

View File

@ -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]

View File

@ -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],

View File

@ -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],

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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],

View File

@ -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

View File

@ -10,7 +10,10 @@
## `Identify <https://docs.libp2p.io/concepts/protocols/#identify>`_ and
## `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 chronos, chronicles

View File

@ -9,7 +9,10 @@
## `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 bearssl/[rand, hash]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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 "../../.."/[

View File

@ -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"

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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

View File

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

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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()