Remove nim 1.2 support (#907)
This commit is contained in:
parent
41649f0999
commit
c76d1e18ef
|
@ -28,7 +28,7 @@ jobs:
|
||||||
cpu: amd64
|
cpu: amd64
|
||||||
#- os: windows
|
#- os: windows
|
||||||
#cpu: i386
|
#cpu: i386
|
||||||
branch: [version-1-2, version-1-6]
|
branch: [version-1-6]
|
||||||
include:
|
include:
|
||||||
- target:
|
- target:
|
||||||
os: linux
|
os: linux
|
||||||
|
|
|
@ -27,7 +27,7 @@ jobs:
|
||||||
cpu: amd64
|
cpu: amd64
|
||||||
#- os: windows
|
#- os: windows
|
||||||
#cpu: i386
|
#cpu: i386
|
||||||
branch: [version-1-2, version-1-6, devel]
|
branch: [version-1-6, version-2-0, devel]
|
||||||
include:
|
include:
|
||||||
- target:
|
- target:
|
||||||
os: linux
|
os: linux
|
||||||
|
@ -48,7 +48,7 @@ jobs:
|
||||||
|
|
||||||
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})'
|
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})'
|
||||||
runs-on: ${{ matrix.builder }}
|
runs-on: ${{ matrix.builder }}
|
||||||
continue-on-error: ${{ matrix.branch == 'devel' }}
|
continue-on-error: ${{ matrix.branch == 'devel' || matrix.branch == 'version-2-0' }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
|
@ -105,7 +105,7 @@ The versioning follows [semver](https://semver.org/), with some additions:
|
||||||
- Some of libp2p procedures are marked as `.public.`, they will remain compatible during each `MAJOR` version
|
- Some of libp2p procedures are marked as `.public.`, they will remain compatible during each `MAJOR` version
|
||||||
- The rest of the procedures are considered internal, and can change at any `MINOR` version (but remain compatible for each new `PATCH`)
|
- The rest of the procedures are considered internal, and can change at any `MINOR` version (but remain compatible for each new `PATCH`)
|
||||||
|
|
||||||
We aim to be compatible at all time with at least 2 Nim `MINOR` versions, currently `1.2 & 1.6`
|
We aim to be compatible at all time with at least 2 Nim `MINOR` versions, currently `1.6 & 2.0`
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
Clone and Install dependencies:
|
Clone and Install dependencies:
|
||||||
|
|
|
@ -9,11 +9,8 @@ switch("warning", "ObservableStores:off")
|
||||||
switch("warning", "LockLevel:off")
|
switch("warning", "LockLevel:off")
|
||||||
--define:chronosStrictException
|
--define:chronosStrictException
|
||||||
--styleCheck:usages
|
--styleCheck:usages
|
||||||
if (NimMajor, NimMinor) < (1, 6):
|
switch("warningAsError", "UseBase:on")
|
||||||
--styleCheck:hint
|
--styleCheck:error
|
||||||
else:
|
|
||||||
switch("warningAsError", "UseBase:on")
|
|
||||||
--styleCheck:error
|
|
||||||
|
|
||||||
# Avoid some rare stack corruption while using exceptions with a SEH-enabled
|
# Avoid some rare stack corruption while using exceptions with a SEH-enabled
|
||||||
# toolchain: https://github.com/status-im/nimbus-eth2/issues/3121
|
# toolchain: https://github.com/status-im/nimbus-eth2/issues/3121
|
||||||
|
|
|
@ -7,7 +7,7 @@ description = "LibP2P implementation"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
skipDirs = @["tests", "examples", "Nim", "tools", "scripts", "docs"]
|
skipDirs = @["tests", "examples", "Nim", "tools", "scripts", "docs"]
|
||||||
|
|
||||||
requires "nim >= 1.2.0",
|
requires "nim >= 1.6.0",
|
||||||
"nimcrypto >= 0.4.1",
|
"nimcrypto >= 0.4.1",
|
||||||
"dnsclient >= 0.3.0 & < 0.4.0",
|
"dnsclient >= 0.3.0 & < 0.4.0",
|
||||||
"bearssl >= 0.1.4",
|
"bearssl >= 0.1.4",
|
||||||
|
@ -104,15 +104,12 @@ task examples_build, "Build the samples":
|
||||||
buildSample("circuitrelay", true)
|
buildSample("circuitrelay", true)
|
||||||
buildSample("tutorial_1_connect", true)
|
buildSample("tutorial_1_connect", true)
|
||||||
buildSample("tutorial_2_customproto", true)
|
buildSample("tutorial_2_customproto", true)
|
||||||
if (NimMajor, NimMinor) > (1, 2):
|
buildSample("tutorial_3_protobuf", true)
|
||||||
# These tutorials relies on post 1.4 exception tracking
|
buildSample("tutorial_4_gossipsub", true)
|
||||||
buildSample("tutorial_3_protobuf", true)
|
buildSample("tutorial_5_discovery", true)
|
||||||
buildSample("tutorial_4_gossipsub", true)
|
exec "nimble install -y nimpng@#HEAD" # this is to fix broken build on 1.7.3, remove it when nimpng version 0.3.2 or later is released
|
||||||
buildSample("tutorial_5_discovery", true)
|
exec "nimble install -y nico"
|
||||||
# Nico doesn't work in 1.2
|
buildSample("tutorial_6_game", false, "--styleCheck:off")
|
||||||
exec "nimble install -y nimpng@#HEAD" # this is to fix broken build on 1.7.3, remove it when nimpng version 0.3.2 or later is released
|
|
||||||
exec "nimble install -y nico"
|
|
||||||
buildSample("tutorial_6_game", false, "--styleCheck:off")
|
|
||||||
|
|
||||||
# pin system
|
# pin system
|
||||||
# while nimble lockfile
|
# while nimble lockfile
|
||||||
|
|
|
@ -16,10 +16,7 @@ runnableExamples:
|
||||||
# etc
|
# etc
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import
|
import
|
||||||
options, tables, chronos, chronicles, sequtils,
|
options, tables, chronos, chronicles, sequtils,
|
||||||
|
@ -36,7 +33,7 @@ export
|
||||||
switch, peerid, peerinfo, connection, multiaddress, crypto, errors
|
switch, peerid, peerinfo, connection, multiaddress, crypto, errors
|
||||||
|
|
||||||
type
|
type
|
||||||
TransportProvider* {.public.} = proc(upgr: Upgrade): Transport {.gcsafe, raises: [Defect].}
|
TransportProvider* {.public.} = proc(upgr: Upgrade): Transport {.gcsafe, raises: [].}
|
||||||
|
|
||||||
SecureProtocol* {.pure.} = enum
|
SecureProtocol* {.pure.} = enum
|
||||||
Noise,
|
Noise,
|
||||||
|
@ -205,7 +202,7 @@ proc withServices*(b: SwitchBuilder, services: seq[Service]): SwitchBuilder =
|
||||||
b
|
b
|
||||||
|
|
||||||
proc build*(b: SwitchBuilder): Switch
|
proc build*(b: SwitchBuilder): Switch
|
||||||
{.raises: [Defect, LPError], public.} =
|
{.raises: [LPError], public.} =
|
||||||
|
|
||||||
if b.rng == nil: # newRng could fail
|
if b.rng == nil: # newRng could fail
|
||||||
raise newException(Defect, "Cannot initialize RNG")
|
raise newException(Defect, "Cannot initialize RNG")
|
||||||
|
@ -296,7 +293,7 @@ proc newStandardSwitch*(
|
||||||
nameResolver: NameResolver = nil,
|
nameResolver: NameResolver = nil,
|
||||||
sendSignedPeerRecord = false,
|
sendSignedPeerRecord = false,
|
||||||
peerStoreCapacity = 1000): Switch
|
peerStoreCapacity = 1000): Switch
|
||||||
{.raises: [Defect, LPError], public.} =
|
{.raises: [LPError], public.} =
|
||||||
## Helper for common switch configurations.
|
## Helper for common switch configurations.
|
||||||
{.push warning[Deprecated]:off.}
|
{.push warning[Deprecated]:off.}
|
||||||
if SecureProtocol.Secio in secureManagers:
|
if SecureProtocol.Secio in secureManagers:
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
|
|
||||||
## This module implementes CID (Content IDentifier).
|
## This module implementes CID (Content IDentifier).
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import tables, hashes
|
import tables, hashes
|
||||||
import multibase, multicodec, multihash, vbuffer, varint
|
import multibase, multicodec, multihash, vbuffer, varint
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.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]
|
||||||
|
@ -51,7 +48,7 @@ type
|
||||||
|
|
||||||
ConnEventHandler* =
|
ConnEventHandler* =
|
||||||
proc(peerId: PeerId, event: ConnEvent): Future[void]
|
proc(peerId: PeerId, event: ConnEvent): Future[void]
|
||||||
{.gcsafe, raises: [Defect].}
|
{.gcsafe, raises: [].}
|
||||||
|
|
||||||
PeerEventKind* {.pure.} = enum
|
PeerEventKind* {.pure.} = enum
|
||||||
Left,
|
Left,
|
||||||
|
@ -65,7 +62,7 @@ type
|
||||||
discard
|
discard
|
||||||
|
|
||||||
PeerEventHandler* =
|
PeerEventHandler* =
|
||||||
proc(peerId: PeerId, event: PeerEvent): Future[void] {.gcsafe, raises: [Defect].}
|
proc(peerId: PeerId, event: PeerEvent): Future[void] {.gcsafe, raises: [].}
|
||||||
|
|
||||||
ConnManager* = ref object of RootObj
|
ConnManager* = ref object of RootObj
|
||||||
maxConnsPerPeer: int
|
maxConnsPerPeer: int
|
||||||
|
@ -285,7 +282,7 @@ proc selectMuxer*(c: ConnManager, peerId: PeerId): Muxer =
|
||||||
|
|
||||||
proc storeMuxer*(c: ConnManager,
|
proc storeMuxer*(c: ConnManager,
|
||||||
muxer: Muxer)
|
muxer: Muxer)
|
||||||
{.raises: [Defect, CatchableError].} =
|
{.raises: [CatchableError].} =
|
||||||
## store the connection and muxer
|
## store the connection and muxer
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@ -338,7 +335,7 @@ proc getIncomingSlot*(c: ConnManager): Future[ConnectionSlot] {.async.} =
|
||||||
await c.inSema.acquire()
|
await c.inSema.acquire()
|
||||||
return ConnectionSlot(connManager: c, direction: In)
|
return ConnectionSlot(connManager: c, direction: In)
|
||||||
|
|
||||||
proc getOutgoingSlot*(c: ConnManager, forceDial = false): ConnectionSlot {.raises: [Defect, TooManyConnectionsError].} =
|
proc getOutgoingSlot*(c: ConnManager, forceDial = false): ConnectionSlot {.raises: [TooManyConnectionsError].} =
|
||||||
if forceDial:
|
if forceDial:
|
||||||
c.outSema.forceAcquire()
|
c.outSema.forceAcquire()
|
||||||
elif not c.outSema.tryAcquire():
|
elif not c.outSema.tryAcquire():
|
||||||
|
|
|
@ -15,10 +15,7 @@
|
||||||
|
|
||||||
# RFC @ https://tools.ietf.org/html/rfc7539
|
# RFC @ https://tools.ietf.org/html/rfc7539
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import bearssl/blockx
|
import bearssl/blockx
|
||||||
from stew/assign2 import assign
|
from stew/assign2 import assign
|
||||||
|
|
|
@ -8,10 +8,7 @@
|
||||||
# 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.
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
from strutils import split, strip, cmpIgnoreCase
|
from strutils import split, strip, cmpIgnoreCase
|
||||||
|
|
||||||
|
@ -1003,27 +1000,27 @@ proc decodeExchange*(message: seq[byte],
|
||||||
## Serialization/Deserialization helpers
|
## Serialization/Deserialization helpers
|
||||||
|
|
||||||
proc write*(vb: var VBuffer, pubkey: PublicKey) {.
|
proc write*(vb: var VBuffer, pubkey: PublicKey) {.
|
||||||
inline, raises: [Defect, ResultError[CryptoError]].} =
|
inline, raises: [ResultError[CryptoError]].} =
|
||||||
## Write PublicKey value ``pubkey`` to buffer ``vb``.
|
## Write PublicKey value ``pubkey`` to buffer ``vb``.
|
||||||
vb.writeSeq(pubkey.getBytes().tryGet())
|
vb.writeSeq(pubkey.getBytes().tryGet())
|
||||||
|
|
||||||
proc write*(vb: var VBuffer, seckey: PrivateKey) {.
|
proc write*(vb: var VBuffer, seckey: PrivateKey) {.
|
||||||
inline, raises: [Defect, ResultError[CryptoError]].} =
|
inline, raises: [ResultError[CryptoError]].} =
|
||||||
## Write PrivateKey value ``seckey`` to buffer ``vb``.
|
## Write PrivateKey value ``seckey`` to buffer ``vb``.
|
||||||
vb.writeSeq(seckey.getBytes().tryGet())
|
vb.writeSeq(seckey.getBytes().tryGet())
|
||||||
|
|
||||||
proc write*(vb: var VBuffer, sig: PrivateKey) {.
|
proc write*(vb: var VBuffer, sig: PrivateKey) {.
|
||||||
inline, raises: [Defect, ResultError[CryptoError]].} =
|
inline, raises: [ResultError[CryptoError]].} =
|
||||||
## Write Signature value ``sig`` to buffer ``vb``.
|
## Write Signature value ``sig`` to buffer ``vb``.
|
||||||
vb.writeSeq(sig.getBytes().tryGet())
|
vb.writeSeq(sig.getBytes().tryGet())
|
||||||
|
|
||||||
proc write*[T: PublicKey|PrivateKey](pb: var ProtoBuffer, field: int,
|
proc write*[T: PublicKey|PrivateKey](pb: var ProtoBuffer, field: int,
|
||||||
key: T) {.
|
key: T) {.
|
||||||
inline, raises: [Defect, ResultError[CryptoError]].} =
|
inline, raises: [ResultError[CryptoError]].} =
|
||||||
write(pb, field, key.getBytes().tryGet())
|
write(pb, field, key.getBytes().tryGet())
|
||||||
|
|
||||||
proc write*(pb: var ProtoBuffer, field: int, sig: Signature) {.
|
proc write*(pb: var ProtoBuffer, field: int, sig: Signature) {.
|
||||||
inline, raises: [Defect].} =
|
inline, raises: [].} =
|
||||||
write(pb, field, sig.getBytes())
|
write(pb, field, sig.getBytes())
|
||||||
|
|
||||||
proc getField*[T: PublicKey|PrivateKey](pb: ProtoBuffer, field: int,
|
proc getField*[T: PublicKey|PrivateKey](pb: ProtoBuffer, field: int,
|
||||||
|
|
|
@ -15,10 +15,7 @@
|
||||||
|
|
||||||
# RFC @ https://tools.ietf.org/html/rfc7748
|
# RFC @ https://tools.ietf.org/html/rfc7748
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import bearssl/[ec, rand]
|
import bearssl/[ec, rand]
|
||||||
import stew/results
|
import stew/results
|
||||||
|
|
|
@ -14,10 +14,7 @@
|
||||||
## 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>.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.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.
|
||||||
|
|
|
@ -11,10 +11,7 @@
|
||||||
## 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import bearssl/rand
|
import bearssl/rand
|
||||||
import constants
|
import constants
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
|
|
||||||
# https://tools.ietf.org/html/rfc5869
|
# https://tools.ietf.org/html/rfc5869
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import nimcrypto
|
import nimcrypto
|
||||||
import bearssl/[kdf, hash]
|
import bearssl/[kdf, hash]
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
|
|
||||||
## This module implements minimal ASN.1 encoding/decoding primitives.
|
## This module implements minimal ASN.1 encoding/decoding primitives.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import stew/[endians2, results, ctops]
|
import stew/[endians2, results, ctops]
|
||||||
export results
|
export results
|
||||||
|
|
|
@ -13,10 +13,7 @@
|
||||||
## 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>.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import bearssl/[rsa, rand, hash]
|
import bearssl/[rsa, rand, hash]
|
||||||
import minasn1
|
import minasn1
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import bearssl/rand
|
import bearssl/rand
|
||||||
import
|
import
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.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]
|
||||||
|
@ -153,10 +150,10 @@ type
|
||||||
key*: PublicKey
|
key*: PublicKey
|
||||||
|
|
||||||
P2PStreamCallback* = proc(api: DaemonAPI,
|
P2PStreamCallback* = proc(api: DaemonAPI,
|
||||||
stream: P2PStream): Future[void] {.gcsafe, raises: [Defect, CatchableError].}
|
stream: P2PStream): Future[void] {.gcsafe, raises: [CatchableError].}
|
||||||
P2PPubSubCallback* = proc(api: DaemonAPI,
|
P2PPubSubCallback* = proc(api: DaemonAPI,
|
||||||
ticket: PubsubTicket,
|
ticket: PubsubTicket,
|
||||||
message: PubSubMessage): Future[bool] {.gcsafe, raises: [Defect, CatchableError].}
|
message: PubSubMessage): Future[bool] {.gcsafe, raises: [CatchableError].}
|
||||||
|
|
||||||
DaemonError* = object of LPError
|
DaemonError* = object of LPError
|
||||||
DaemonRemoteError* = object of DaemonError
|
DaemonRemoteError* = object of DaemonError
|
||||||
|
@ -474,7 +471,7 @@ proc checkResponse(pb: ProtoBuffer): ResponseKind {.inline.} =
|
||||||
else:
|
else:
|
||||||
result = ResponseKind.Error
|
result = ResponseKind.Error
|
||||||
|
|
||||||
proc getErrorMessage(pb: ProtoBuffer): string {.inline, raises: [Defect, DaemonLocalError].} =
|
proc getErrorMessage(pb: ProtoBuffer): string {.inline, raises: [DaemonLocalError].} =
|
||||||
var error: seq[byte]
|
var error: seq[byte]
|
||||||
if pb.getRequiredField(ResponseType.ERROR.int, error).isOk():
|
if pb.getRequiredField(ResponseType.ERROR.int, error).isOk():
|
||||||
if initProtoBuffer(error).getRequiredField(1, result).isErr():
|
if initProtoBuffer(error).getRequiredField(1, result).isErr():
|
||||||
|
@ -504,7 +501,7 @@ proc recvMessage(conn: StreamTransport): Future[seq[byte]] {.async.} =
|
||||||
result = buffer
|
result = buffer
|
||||||
|
|
||||||
proc newConnection*(api: DaemonAPI): Future[StreamTransport]
|
proc newConnection*(api: DaemonAPI): Future[StreamTransport]
|
||||||
{.raises: [Defect, LPError].} =
|
{.raises: [LPError].} =
|
||||||
result = connect(api.address)
|
result = connect(api.address)
|
||||||
|
|
||||||
proc closeConnection*(api: DaemonAPI, transp: StreamTransport): Future[void] =
|
proc closeConnection*(api: DaemonAPI, transp: StreamTransport): Future[void] =
|
||||||
|
@ -515,7 +512,7 @@ proc socketExists(address: MultiAddress): Future[bool] {.async.} =
|
||||||
var transp = await connect(address)
|
var transp = await connect(address)
|
||||||
await transp.closeWait()
|
await transp.closeWait()
|
||||||
result = true
|
result = true
|
||||||
except CatchableError, Defect:
|
except CatchableError:
|
||||||
result = false
|
result = false
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
|
@ -837,7 +834,7 @@ proc transactMessage(transp: StreamTransport,
|
||||||
result = initProtoBuffer(message)
|
result = initProtoBuffer(message)
|
||||||
|
|
||||||
proc getPeerInfo(pb: ProtoBuffer): PeerInfo
|
proc getPeerInfo(pb: ProtoBuffer): PeerInfo
|
||||||
{.raises: [Defect, DaemonLocalError].} =
|
{.raises: [DaemonLocalError].} =
|
||||||
## Get PeerInfo object from ``pb``.
|
## Get PeerInfo object from ``pb``.
|
||||||
result.addresses = newSeq[MultiAddress]()
|
result.addresses = newSeq[MultiAddress]()
|
||||||
if pb.getRequiredField(1, result.peer).isErr():
|
if pb.getRequiredField(1, result.peer).isErr():
|
||||||
|
@ -868,7 +865,7 @@ proc connect*(api: DaemonAPI, peer: PeerId,
|
||||||
timeout))
|
timeout))
|
||||||
pb.withMessage() do:
|
pb.withMessage() do:
|
||||||
discard
|
discard
|
||||||
except CatchableError, Defect:
|
except CatchableError:
|
||||||
await api.closeConnection(transp)
|
await api.closeConnection(transp)
|
||||||
|
|
||||||
proc disconnect*(api: DaemonAPI, peer: PeerId) {.async.} =
|
proc disconnect*(api: DaemonAPI, peer: PeerId) {.async.} =
|
||||||
|
@ -928,7 +925,7 @@ proc streamHandler(server: StreamServer, transp: StreamTransport) {.async.} =
|
||||||
asyncSpawn handler(api, stream)
|
asyncSpawn handler(api, stream)
|
||||||
|
|
||||||
proc addHandler*(api: DaemonAPI, protocols: seq[string],
|
proc addHandler*(api: DaemonAPI, protocols: seq[string],
|
||||||
handler: P2PStreamCallback) {.async, raises: [Defect, LPError].} =
|
handler: P2PStreamCallback) {.async, raises: [LPError].} =
|
||||||
## Add stream handler ``handler`` for set of protocols ``protocols``.
|
## Add stream handler ``handler`` for set of protocols ``protocols``.
|
||||||
var transp = await api.newConnection()
|
var transp = await api.newConnection()
|
||||||
let maddress = await getSocket(api.pattern, addr api.ucounter)
|
let maddress = await getSocket(api.pattern, addr api.ucounter)
|
||||||
|
@ -998,7 +995,7 @@ proc cmTrimPeers*(api: DaemonAPI) {.async.} =
|
||||||
await api.closeConnection(transp)
|
await api.closeConnection(transp)
|
||||||
|
|
||||||
proc dhtGetSinglePeerInfo(pb: ProtoBuffer): PeerInfo
|
proc dhtGetSinglePeerInfo(pb: ProtoBuffer): PeerInfo
|
||||||
{.raises: [Defect, DaemonLocalError].} =
|
{.raises: [DaemonLocalError].} =
|
||||||
var res: seq[byte]
|
var res: seq[byte]
|
||||||
if pb.getRequiredField(2, res).isOk():
|
if pb.getRequiredField(2, res).isOk():
|
||||||
result = initProtoBuffer(res).getPeerInfo()
|
result = initProtoBuffer(res).getPeerInfo()
|
||||||
|
@ -1006,23 +1003,23 @@ proc dhtGetSinglePeerInfo(pb: ProtoBuffer): PeerInfo
|
||||||
raise newException(DaemonLocalError, "Missing required field `peer`!")
|
raise newException(DaemonLocalError, "Missing required field `peer`!")
|
||||||
|
|
||||||
proc dhtGetSingleValue(pb: ProtoBuffer): seq[byte]
|
proc dhtGetSingleValue(pb: ProtoBuffer): seq[byte]
|
||||||
{.raises: [Defect, DaemonLocalError].} =
|
{.raises: [DaemonLocalError].} =
|
||||||
result = newSeq[byte]()
|
result = newSeq[byte]()
|
||||||
if pb.getRequiredField(3, result).isErr():
|
if pb.getRequiredField(3, result).isErr():
|
||||||
raise newException(DaemonLocalError, "Missing field `value`!")
|
raise newException(DaemonLocalError, "Missing field `value`!")
|
||||||
|
|
||||||
proc dhtGetSinglePublicKey(pb: ProtoBuffer): PublicKey
|
proc dhtGetSinglePublicKey(pb: ProtoBuffer): PublicKey
|
||||||
{.raises: [Defect, DaemonLocalError].} =
|
{.raises: [DaemonLocalError].} =
|
||||||
if pb.getRequiredField(3, result).isErr():
|
if pb.getRequiredField(3, result).isErr():
|
||||||
raise newException(DaemonLocalError, "Missing field `value`!")
|
raise newException(DaemonLocalError, "Missing field `value`!")
|
||||||
|
|
||||||
proc dhtGetSinglePeerId(pb: ProtoBuffer): PeerId
|
proc dhtGetSinglePeerId(pb: ProtoBuffer): PeerId
|
||||||
{.raises: [Defect, DaemonLocalError].} =
|
{.raises: [DaemonLocalError].} =
|
||||||
if pb.getRequiredField(3, result).isErr():
|
if pb.getRequiredField(3, result).isErr():
|
||||||
raise newException(DaemonLocalError, "Missing field `value`!")
|
raise newException(DaemonLocalError, "Missing field `value`!")
|
||||||
|
|
||||||
proc enterDhtMessage(pb: ProtoBuffer, rt: DHTResponseType): ProtoBuffer
|
proc enterDhtMessage(pb: ProtoBuffer, rt: DHTResponseType): ProtoBuffer
|
||||||
{.inline, raises: [Defect, DaemonLocalError].} =
|
{.inline, raises: [DaemonLocalError].} =
|
||||||
var dhtResponse: seq[byte]
|
var dhtResponse: seq[byte]
|
||||||
if pb.getRequiredField(ResponseType.DHT.int, dhtResponse).isOk():
|
if pb.getRequiredField(ResponseType.DHT.int, dhtResponse).isOk():
|
||||||
var pbDhtResponse = initProtoBuffer(dhtResponse)
|
var pbDhtResponse = initProtoBuffer(dhtResponse)
|
||||||
|
@ -1041,7 +1038,7 @@ proc enterDhtMessage(pb: ProtoBuffer, rt: DHTResponseType): ProtoBuffer
|
||||||
raise newException(DaemonLocalError, "Wrong message type!")
|
raise newException(DaemonLocalError, "Wrong message type!")
|
||||||
|
|
||||||
proc enterPsMessage(pb: ProtoBuffer): ProtoBuffer
|
proc enterPsMessage(pb: ProtoBuffer): ProtoBuffer
|
||||||
{.inline, raises: [Defect, DaemonLocalError].} =
|
{.inline, raises: [DaemonLocalError].} =
|
||||||
var res: seq[byte]
|
var res: seq[byte]
|
||||||
if pb.getRequiredField(ResponseType.PUBSUB.int, res).isErr():
|
if pb.getRequiredField(ResponseType.PUBSUB.int, res).isErr():
|
||||||
raise newException(DaemonLocalError, "Wrong message type!")
|
raise newException(DaemonLocalError, "Wrong message type!")
|
||||||
|
@ -1049,7 +1046,7 @@ proc enterPsMessage(pb: ProtoBuffer): ProtoBuffer
|
||||||
initProtoBuffer(res)
|
initProtoBuffer(res)
|
||||||
|
|
||||||
proc getDhtMessageType(pb: ProtoBuffer): DHTResponseType
|
proc getDhtMessageType(pb: ProtoBuffer): DHTResponseType
|
||||||
{.inline, raises: [Defect, DaemonLocalError].} =
|
{.inline, raises: [DaemonLocalError].} =
|
||||||
var dtype: uint
|
var dtype: uint
|
||||||
if pb.getRequiredField(1, dtype).isErr():
|
if pb.getRequiredField(1, dtype).isErr():
|
||||||
raise newException(DaemonLocalError, "Missing required DHT field `type`!")
|
raise newException(DaemonLocalError, "Missing required DHT field `type`!")
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
## This module implements Pool of StreamTransport.
|
## This module implements Pool of StreamTransport.
|
||||||
import chronos
|
import chronos
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import chronos
|
import chronos
|
||||||
import stew/results
|
import stew/results
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/sequtils
|
import std/sequtils
|
||||||
import chronos, chronicles, stew/results
|
import chronos, chronicles, stew/results
|
||||||
|
@ -18,7 +15,7 @@ import ../errors
|
||||||
|
|
||||||
type
|
type
|
||||||
BaseAttr = ref object of RootObj
|
BaseAttr = ref object of RootObj
|
||||||
comparator: proc(f, c: BaseAttr): bool {.gcsafe, raises: [Defect].}
|
comparator: proc(f, c: BaseAttr): bool {.gcsafe, raises: [].}
|
||||||
|
|
||||||
Attribute[T] = ref object of BaseAttr
|
Attribute[T] = ref object of BaseAttr
|
||||||
value: T
|
value: T
|
||||||
|
@ -60,7 +57,7 @@ proc `{}`*[T](pa: PeerAttributes, t: typedesc[T]): Opt[T] =
|
||||||
return Opt.some(f.to(T))
|
return Opt.some(f.to(T))
|
||||||
Opt.none(T)
|
Opt.none(T)
|
||||||
|
|
||||||
proc `[]`*[T](pa: PeerAttributes, t: typedesc[T]): T {.raises: [Defect, KeyError].} =
|
proc `[]`*[T](pa: PeerAttributes, t: typedesc[T]): T {.raises: [KeyError].} =
|
||||||
pa{T}.valueOr: raise newException(KeyError, "Attritute not found")
|
pa{T}.valueOr: raise newException(KeyError, "Attritute not found")
|
||||||
|
|
||||||
proc match*(pa, candidate: PeerAttributes): bool =
|
proc match*(pa, candidate: PeerAttributes): bool =
|
||||||
|
@ -73,7 +70,7 @@ proc match*(pa, candidate: PeerAttributes): bool =
|
||||||
return true
|
return true
|
||||||
|
|
||||||
type
|
type
|
||||||
PeerFoundCallback* = proc(pa: PeerAttributes) {.raises: [Defect], gcsafe.}
|
PeerFoundCallback* = proc(pa: PeerAttributes) {.raises: [], gcsafe.}
|
||||||
|
|
||||||
DiscoveryInterface* = ref object of RootObj
|
DiscoveryInterface* = ref object of RootObj
|
||||||
onPeerFound*: PeerFoundCallback
|
onPeerFound*: PeerFoundCallback
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import chronos
|
import chronos
|
||||||
import ./discoverymngr,
|
import ./discoverymngr,
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
|
|
||||||
## This module implements MultiAddress.
|
## This module implements MultiAddress.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
{.push public.}
|
{.push public.}
|
||||||
|
|
||||||
import pkg/chronos, chronicles
|
import pkg/chronos, chronicles
|
||||||
|
@ -775,7 +772,7 @@ proc toString*(value: MultiAddress): MaResult[string] =
|
||||||
res = "/" & parts.join("/")
|
res = "/" & parts.join("/")
|
||||||
ok(res)
|
ok(res)
|
||||||
|
|
||||||
proc `$`*(value: MultiAddress): string {.raises: [Defect].} =
|
proc `$`*(value: MultiAddress): string =
|
||||||
## Return string representation of MultiAddress ``value``.
|
## Return string representation of MultiAddress ``value``.
|
||||||
let s = value.toString()
|
let s = value.toString()
|
||||||
if s.isErr: s.error
|
if s.isErr: s.error
|
||||||
|
@ -1025,7 +1022,7 @@ proc append*(m1: var MultiAddress, m2: MultiAddress): MaResult[void] =
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
proc `&`*(m1, m2: MultiAddress): MultiAddress {.
|
proc `&`*(m1, m2: MultiAddress): MultiAddress {.
|
||||||
raises: [Defect, LPError].} =
|
raises: [LPError].} =
|
||||||
## Concatenates two addresses ``m1`` and ``m2``, and returns result.
|
## Concatenates two addresses ``m1`` and ``m2``, and returns result.
|
||||||
##
|
##
|
||||||
## This procedure performs validation of concatenated result and can raise
|
## This procedure performs validation of concatenated result and can raise
|
||||||
|
@ -1035,7 +1032,7 @@ proc `&`*(m1, m2: MultiAddress): MultiAddress {.
|
||||||
concat(m1, m2).tryGet()
|
concat(m1, m2).tryGet()
|
||||||
|
|
||||||
proc `&=`*(m1: var MultiAddress, m2: MultiAddress) {.
|
proc `&=`*(m1: var MultiAddress, m2: MultiAddress) {.
|
||||||
raises: [Defect, LPError].} =
|
raises: [LPError].} =
|
||||||
## Concatenates two addresses ``m1`` and ``m2``.
|
## Concatenates two addresses ``m1`` and ``m2``.
|
||||||
##
|
##
|
||||||
## This procedure performs validation of concatenated result and can raise
|
## This procedure performs validation of concatenated result and can raise
|
||||||
|
|
|
@ -13,10 +13,7 @@
|
||||||
## 1. base32z
|
## 1. base32z
|
||||||
##
|
##
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import tables
|
import tables
|
||||||
import stew/[base32, base58, base64, results]
|
import stew/[base32, base58, base64, results]
|
||||||
|
@ -27,17 +24,17 @@ type
|
||||||
|
|
||||||
MultiBase* = object
|
MultiBase* = object
|
||||||
|
|
||||||
MBCodeSize = proc(length: int): int {.nimcall, gcsafe, noSideEffect, raises: [Defect].}
|
MBCodeSize = proc(length: int): int {.nimcall, gcsafe, noSideEffect, raises: [].}
|
||||||
|
|
||||||
MBCodec = object
|
MBCodec = object
|
||||||
code: char
|
code: char
|
||||||
name: string
|
name: string
|
||||||
encr: proc(inbytes: openArray[byte],
|
encr: proc(inbytes: openArray[byte],
|
||||||
outbytes: var openArray[char],
|
outbytes: var openArray[char],
|
||||||
outlen: var int): MultiBaseStatus {.nimcall, gcsafe, noSideEffect, raises: [Defect].}
|
outlen: var int): MultiBaseStatus {.nimcall, gcsafe, noSideEffect, raises: [].}
|
||||||
decr: proc(inbytes: openArray[char],
|
decr: proc(inbytes: openArray[char],
|
||||||
outbytes: var openArray[byte],
|
outbytes: var openArray[byte],
|
||||||
outlen: var int): MultiBaseStatus {.nimcall, gcsafe, noSideEffect, raises: [Defect].}
|
outlen: var int): MultiBaseStatus {.nimcall, gcsafe, noSideEffect, raises: [].}
|
||||||
encl: MBCodeSize
|
encl: MBCodeSize
|
||||||
decl: MBCodeSize
|
decl: MBCodeSize
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
|
|
||||||
## This module implements MultiCodec.
|
## This module implements MultiCodec.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import tables, hashes
|
import tables, hashes
|
||||||
import varint, vbuffer
|
import varint, vbuffer
|
||||||
|
|
|
@ -21,10 +21,7 @@
|
||||||
## 1. SKEIN
|
## 1. SKEIN
|
||||||
## 2. MURMUR
|
## 2. MURMUR
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.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]
|
||||||
|
@ -45,7 +42,7 @@ const
|
||||||
|
|
||||||
type
|
type
|
||||||
MHashCoderProc* = proc(data: openArray[byte],
|
MHashCoderProc* = proc(data: openArray[byte],
|
||||||
output: var openArray[byte]) {.nimcall, gcsafe, noSideEffect, raises: [Defect].}
|
output: var openArray[byte]) {.nimcall, gcsafe, noSideEffect, raises: [].}
|
||||||
MHash* = object
|
MHash* = object
|
||||||
mcodec*: MultiCodec
|
mcodec*: MultiCodec
|
||||||
size*: int
|
size*: int
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[strutils, sequtils, tables]
|
import std/[strutils, sequtils, tables]
|
||||||
import chronos, chronicles, stew/byteutils
|
import chronos, chronicles, stew/byteutils
|
||||||
|
@ -28,7 +25,7 @@ const
|
||||||
Ls = "ls\n"
|
Ls = "ls\n"
|
||||||
|
|
||||||
type
|
type
|
||||||
Matcher* = proc (proto: string): bool {.gcsafe, raises: [Defect].}
|
Matcher* = proc (proto: string): bool {.gcsafe, raises: [].}
|
||||||
|
|
||||||
MultiStreamError* = object of LPError
|
MultiStreamError* = object of LPError
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import pkg/[chronos, chronicles, stew/byteutils]
|
import pkg/[chronos, chronicles, stew/byteutils]
|
||||||
import ../../stream/connection,
|
import ../../stream/connection,
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[oids, strformat]
|
import std/[oids, strformat]
|
||||||
import pkg/[chronos, chronicles, metrics]
|
import pkg/[chronos, chronicles, metrics]
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.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
|
||||||
|
@ -79,7 +76,7 @@ proc newStreamInternal*(m: Mplex,
|
||||||
chanId: uint64 = 0,
|
chanId: uint64 = 0,
|
||||||
name: string = "",
|
name: string = "",
|
||||||
timeout: Duration): LPChannel
|
timeout: Duration): LPChannel
|
||||||
{.gcsafe, raises: [Defect, InvalidChannelIdError].} =
|
{.gcsafe, raises: [InvalidChannelIdError].} =
|
||||||
## create new channel/stream
|
## create new channel/stream
|
||||||
##
|
##
|
||||||
let id = if initiator:
|
let id = if initiator:
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import chronos, chronicles
|
import chronos, chronicles
|
||||||
import ../stream/connection,
|
import ../stream/connection,
|
||||||
|
@ -26,8 +23,8 @@ type
|
||||||
MuxerError* = object of LPError
|
MuxerError* = object of LPError
|
||||||
TooManyChannels* = object of MuxerError
|
TooManyChannels* = object of MuxerError
|
||||||
|
|
||||||
StreamHandler* = proc(conn: Connection): Future[void] {.gcsafe, raises: [Defect].}
|
StreamHandler* = proc(conn: Connection): Future[void] {.gcsafe, raises: [].}
|
||||||
MuxerHandler* = proc(muxer: Muxer): Future[void] {.gcsafe, raises: [Defect].}
|
MuxerHandler* = proc(muxer: Muxer): Future[void] {.gcsafe, raises: [].}
|
||||||
|
|
||||||
Muxer* = ref object of RootObj
|
Muxer* = ref object of RootObj
|
||||||
streamHandler*: StreamHandler
|
streamHandler*: StreamHandler
|
||||||
|
@ -35,7 +32,7 @@ type
|
||||||
connection*: Connection
|
connection*: Connection
|
||||||
|
|
||||||
# user provider proc that returns a constructed Muxer
|
# user provider proc that returns a constructed Muxer
|
||||||
MuxerConstructor* = proc(conn: Connection): Muxer {.gcsafe, closure, raises: [Defect].}
|
MuxerConstructor* = proc(conn: Connection): Muxer {.gcsafe, closure, raises: [].}
|
||||||
|
|
||||||
# this wraps a creator proc that knows how to make muxers
|
# this wraps a creator proc that knows how to make muxers
|
||||||
MuxerProvider* = object
|
MuxerProvider* = object
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.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]
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import
|
import
|
||||||
std/[streams, strutils, sets, sequtils],
|
std/[streams, strutils, sets, sequtils],
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import
|
import
|
||||||
std/tables,
|
std/tables,
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[sugar, sets, sequtils, strutils]
|
import std/[sugar, sets, sequtils, strutils]
|
||||||
import
|
import
|
||||||
|
@ -55,7 +52,7 @@ proc resolveOneAddress(
|
||||||
ma: MultiAddress,
|
ma: MultiAddress,
|
||||||
domain: Domain = Domain.AF_UNSPEC,
|
domain: Domain = Domain.AF_UNSPEC,
|
||||||
prefix = ""): Future[seq[MultiAddress]]
|
prefix = ""): Future[seq[MultiAddress]]
|
||||||
{.async, raises: [Defect, MaError, TransportAddressError].} =
|
{.async, raises: [MaError, TransportAddressError].} =
|
||||||
#Resolve a single address
|
#Resolve a single address
|
||||||
var pbuf: array[2, byte]
|
var pbuf: array[2, byte]
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import
|
import
|
||||||
std/[sequtils, tables],
|
std/[sequtils, tables],
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
|
|
||||||
## This module implementes API for libp2p peer.
|
## This module implementes API for libp2p peer.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
{.push public.}
|
{.push public.}
|
||||||
|
|
||||||
import
|
import
|
||||||
|
@ -44,10 +41,7 @@ func shortLog*(pid: PeerId): string =
|
||||||
if len(spid) > 10:
|
if len(spid) > 10:
|
||||||
spid[3] = '*'
|
spid[3] = '*'
|
||||||
|
|
||||||
when (NimMajor, NimMinor) > (1, 4):
|
spid.delete(4 .. spid.high - 6)
|
||||||
spid.delete(4 .. spid.high - 6)
|
|
||||||
else:
|
|
||||||
spid.delete(4, spid.high - 6)
|
|
||||||
|
|
||||||
spid
|
spid
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
{.push public.}
|
{.push public.}
|
||||||
|
|
||||||
import std/[options, sequtils]
|
import std/[options, sequtils]
|
||||||
|
@ -26,7 +23,7 @@ type
|
||||||
|
|
||||||
AddressMapper* =
|
AddressMapper* =
|
||||||
proc(listenAddrs: seq[MultiAddress]): Future[seq[MultiAddress]]
|
proc(listenAddrs: seq[MultiAddress]): Future[seq[MultiAddress]]
|
||||||
{.gcsafe, raises: [Defect].}
|
{.gcsafe, raises: [].}
|
||||||
|
|
||||||
PeerInfo* {.public.} = ref object
|
PeerInfo* {.public.} = ref object
|
||||||
peerId*: PeerId
|
peerId*: PeerId
|
||||||
|
@ -99,7 +96,7 @@ proc new*(
|
||||||
agentVersion: string = "",
|
agentVersion: string = "",
|
||||||
addressMappers = newSeq[AddressMapper](),
|
addressMappers = newSeq[AddressMapper](),
|
||||||
): PeerInfo
|
): PeerInfo
|
||||||
{.raises: [Defect, LPError].} =
|
{.raises: [LPError].} =
|
||||||
|
|
||||||
let pubkey = try:
|
let pubkey = try:
|
||||||
key.getPublicKey().tryGet()
|
key.getPublicKey().tryGet()
|
||||||
|
|
|
@ -21,10 +21,7 @@ runnableExamples:
|
||||||
peerStore[MoodBook][somePeerId] = "Happy"
|
peerStore[MoodBook][somePeerId] = "Happy"
|
||||||
doAssert peerStore[MoodBook][somePeerId] == "Happy"
|
doAssert peerStore[MoodBook][somePeerId] == "Happy"
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import
|
import
|
||||||
std/[tables, sets, options, macros],
|
std/[tables, sets, options, macros],
|
||||||
|
@ -45,7 +42,7 @@ type
|
||||||
# Handler types #
|
# Handler types #
|
||||||
#################
|
#################
|
||||||
|
|
||||||
PeerBookChangeHandler* = proc(peerId: PeerId) {.gcsafe, raises: [Defect].}
|
PeerBookChangeHandler* = proc(peerId: PeerId) {.gcsafe, raises: [].}
|
||||||
|
|
||||||
#########
|
#########
|
||||||
# Books #
|
# Books #
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
|
|
||||||
## This module implements minimal Google's ProtoBuf primitives.
|
## This module implements minimal Google's ProtoBuf primitives.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import ../varint, ../utility, stew/[endians2, results]
|
import ../varint, ../utility, stew/[endians2, results]
|
||||||
export results, utility
|
export results, utility
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/options
|
import std/options
|
||||||
import stew/results
|
import stew/results
|
||||||
|
@ -36,7 +33,7 @@ proc sendDial(conn: Connection, pid: PeerId, addrs: seq[MultiAddress]) {.async.}
|
||||||
method dialMe*(self: AutonatClient, switch: Switch, pid: PeerId, addrs: seq[MultiAddress] = newSeq[MultiAddress]()):
|
method dialMe*(self: AutonatClient, switch: Switch, pid: PeerId, addrs: seq[MultiAddress] = newSeq[MultiAddress]()):
|
||||||
Future[MultiAddress] {.base, async.} =
|
Future[MultiAddress] {.base, async.} =
|
||||||
|
|
||||||
proc getResponseOrRaise(autonatMsg: Option[AutonatMsg]): AutonatDialResponse {.raises: [Defect, AutonatError].} =
|
proc getResponseOrRaise(autonatMsg: Option[AutonatMsg]): AutonatDialResponse {.raises: [AutonatError].} =
|
||||||
if autonatMsg.isNone() or
|
if autonatMsg.isNone() or
|
||||||
autonatMsg.get().msgType != DialResponse or
|
autonatMsg.get().msgType != DialResponse or
|
||||||
autonatMsg.get().response.isNone() or
|
autonatMsg.get().response.isNone() or
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[options]
|
import std/[options]
|
||||||
import stew/[results, objects]
|
import stew/[results, objects]
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[options, sets, sequtils]
|
import std/[options, sets, sequtils]
|
||||||
import stew/results
|
import stew/results
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[options, deques, sequtils]
|
import std/[options, deques, sequtils]
|
||||||
import chronos, metrics
|
import chronos, metrics
|
||||||
|
@ -47,7 +44,7 @@ type
|
||||||
dialTimeout: Duration
|
dialTimeout: Duration
|
||||||
enableAddressMapper: bool
|
enableAddressMapper: bool
|
||||||
|
|
||||||
StatusAndConfidenceHandler* = proc (networkReachability: NetworkReachability, confidence: Option[float]): Future[void] {.gcsafe, raises: [Defect].}
|
StatusAndConfidenceHandler* = proc (networkReachability: NetworkReachability, confidence: Option[float]): Future[void] {.gcsafe, raises: [].}
|
||||||
|
|
||||||
proc new*(
|
proc new*(
|
||||||
T: typedesc[AutonatService],
|
T: typedesc[AutonatService],
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/sequtils
|
import std/sequtils
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/sequtils
|
import std/sequtils
|
||||||
|
|
||||||
|
@ -44,7 +41,7 @@ proc encode*(msg: DcutrMsg): ProtoBuffer =
|
||||||
result.write(2, addr)
|
result.write(2, addr)
|
||||||
result.finish()
|
result.finish()
|
||||||
|
|
||||||
proc decode*(_: typedesc[DcutrMsg], buf: seq[byte]): DcutrMsg {.raises: [Defect, DcutrError].} =
|
proc decode*(_: typedesc[DcutrMsg], buf: seq[byte]): DcutrMsg {.raises: [DcutrError].} =
|
||||||
var
|
var
|
||||||
msgTypeOrd: uint32
|
msgTypeOrd: uint32
|
||||||
dcutrMsg: DcutrMsg
|
dcutrMsg: DcutrMsg
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[options, sets, sequtils]
|
import std/[options, sets, sequtils]
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import times, options
|
import times, options
|
||||||
|
|
||||||
|
@ -39,7 +36,7 @@ type
|
||||||
RelayV2DialError* = object of RelayClientError
|
RelayV2DialError* = object of RelayClientError
|
||||||
RelayClientAddConn* = proc(conn: Connection,
|
RelayClientAddConn* = proc(conn: Connection,
|
||||||
duration: uint32,
|
duration: uint32,
|
||||||
data: uint64): Future[void] {.gcsafe, raises: [Defect].}
|
data: uint64): Future[void] {.gcsafe, raises: [].}
|
||||||
RelayClient* = ref object of Relay
|
RelayClient* = ref object of Relay
|
||||||
onNewConnection*: RelayClientAddConn
|
onNewConnection*: RelayClientAddConn
|
||||||
canHop: bool
|
canHop: bool
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import options, macros
|
import options, macros
|
||||||
import stew/objects
|
import stew/objects
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import chronos
|
import chronos
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import options, sequtils, tables
|
import options, sequtils, tables
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import sequtils, strutils
|
import sequtils, strutils
|
||||||
|
|
||||||
|
@ -40,7 +37,7 @@ method start*(self: RelayTransport, ma: seq[MultiAddress]) {.async.} =
|
||||||
self.client.onNewConnection = proc(
|
self.client.onNewConnection = proc(
|
||||||
conn: Connection,
|
conn: Connection,
|
||||||
duration: uint32 = 0,
|
duration: uint32 = 0,
|
||||||
data: uint64 = 0) {.async, gcsafe, raises: [Defect].} =
|
data: uint64 = 0) {.async, gcsafe, raises: [].} =
|
||||||
await self.queue.addLast(RelayConnection.new(conn, duration, data))
|
await self.queue.addLast(RelayConnection.new(conn, duration, data))
|
||||||
await conn.join()
|
await conn.join()
|
||||||
self.selfRunning = true
|
self.selfRunning = true
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import options
|
import options
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,7 @@
|
||||||
## `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
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[sequtils, options, strutils, sugar]
|
import std/[sequtils, options, strutils, sugar]
|
||||||
import stew/results
|
import stew/results
|
||||||
|
@ -65,7 +62,7 @@ type
|
||||||
peer: PeerId,
|
peer: PeerId,
|
||||||
newInfo: IdentifyInfo):
|
newInfo: IdentifyInfo):
|
||||||
Future[void]
|
Future[void]
|
||||||
{.gcsafe, raises: [Defect], public.}
|
{.gcsafe, raises: [], public.}
|
||||||
|
|
||||||
IdentifyPush* = ref object of LPProtocol
|
IdentifyPush* = ref object of LPProtocol
|
||||||
identifyHandler: IdentifyPushHandler
|
identifyHandler: IdentifyPushHandler
|
||||||
|
@ -86,7 +83,7 @@ chronicles.expandIt(IdentifyInfo):
|
||||||
else: "None"
|
else: "None"
|
||||||
|
|
||||||
proc encodeMsg(peerInfo: PeerInfo, observedAddr: Opt[MultiAddress], sendSpr: bool): ProtoBuffer
|
proc encodeMsg(peerInfo: PeerInfo, observedAddr: Opt[MultiAddress], sendSpr: bool): ProtoBuffer
|
||||||
{.raises: [Defect].} =
|
{.raises: [].} =
|
||||||
result = initProtoBuffer()
|
result = initProtoBuffer()
|
||||||
|
|
||||||
let pkey = peerInfo.publicKey
|
let pkey = peerInfo.publicKey
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
|
|
||||||
## `Ping <https://docs.libp2p.io/concepts/protocols/#ping>`_ protocol implementation
|
## `Ping <https://docs.libp2p.io/concepts/protocols/#ping>`_ protocol implementation
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import chronos, chronicles
|
import chronos, chronicles
|
||||||
import bearssl/rand
|
import bearssl/rand
|
||||||
|
@ -42,7 +39,7 @@ type
|
||||||
PingHandler* {.public.} = proc (
|
PingHandler* {.public.} = proc (
|
||||||
peer: PeerId):
|
peer: PeerId):
|
||||||
Future[void]
|
Future[void]
|
||||||
{.gcsafe, raises: [Defect].}
|
{.gcsafe, raises: [].}
|
||||||
|
|
||||||
Ping* = ref object of LPProtocol
|
Ping* = ref object of LPProtocol
|
||||||
pingHandler*: PingHandler
|
pingHandler*: PingHandler
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import chronos, stew/results
|
import chronos, stew/results
|
||||||
import ../stream/connection
|
import ../stream/connection
|
||||||
|
@ -25,7 +22,7 @@ type
|
||||||
conn: Connection,
|
conn: Connection,
|
||||||
proto: string):
|
proto: string):
|
||||||
Future[void]
|
Future[void]
|
||||||
{.gcsafe, raises: [Defect].}
|
{.gcsafe, raises: [].}
|
||||||
|
|
||||||
LPProtocol* = ref object of RootObj
|
LPProtocol* = ref object of RootObj
|
||||||
codecs*: seq[string]
|
codecs*: seq[string]
|
||||||
|
@ -55,8 +52,8 @@ func `codec=`*(p: LPProtocol, codec: string) =
|
||||||
proc new*(
|
proc new*(
|
||||||
T: type LPProtocol,
|
T: type LPProtocol,
|
||||||
codecs: seq[string],
|
codecs: seq[string],
|
||||||
handler: LPProtoHandler, # default(Opt[int]) or Opt.none(int) don't work on 1.2
|
handler: LPProtoHandler,
|
||||||
maxIncomingStreams: Opt[int] | int = Opt[int]()): T =
|
maxIncomingStreams: Opt[int] | int = Opt.none(int)): T =
|
||||||
T(
|
T(
|
||||||
codecs: codecs,
|
codecs: codecs,
|
||||||
handler: handler,
|
handler: handler,
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[sets, hashes, tables]
|
import std/[sets, hashes, tables]
|
||||||
import chronos, chronicles, metrics
|
import chronos, chronicles, metrics
|
||||||
|
@ -223,7 +220,7 @@ method publish*(f: FloodSub,
|
||||||
return peers.len
|
return peers.len
|
||||||
|
|
||||||
method initPubSub*(f: FloodSub)
|
method initPubSub*(f: FloodSub)
|
||||||
{.raises: [Defect, InitializationError].} =
|
{.raises: [InitializationError].} =
|
||||||
procCall PubSub(f).initPubSub()
|
procCall PubSub(f).initPubSub()
|
||||||
f.seen = TimedCache[MessageId].init(2.minutes)
|
f.seen = TimedCache[MessageId].init(2.minutes)
|
||||||
f.seenSalt = newSeqUninitialized[byte](sizeof(Hash))
|
f.seenSalt = newSeqUninitialized[byte](sizeof(Hash))
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
|
|
||||||
## Gossip based publishing
|
## Gossip based publishing
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[sets, sequtils]
|
import std/[sets, sequtils]
|
||||||
import chronos, chronicles, metrics
|
import chronos, chronicles, metrics
|
||||||
|
@ -622,7 +619,7 @@ method stop*(g: GossipSub) {.async.} =
|
||||||
g.heartbeatFut = nil
|
g.heartbeatFut = nil
|
||||||
|
|
||||||
method initPubSub*(g: GossipSub)
|
method initPubSub*(g: GossipSub)
|
||||||
{.raises: [Defect, InitializationError].} =
|
{.raises: [InitializationError].} =
|
||||||
procCall FloodSub(g).initPubSub()
|
procCall FloodSub(g).initPubSub()
|
||||||
|
|
||||||
if not g.parameters.explicit:
|
if not g.parameters.explicit:
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[tables, sequtils, sets, algorithm, deques]
|
import std/[tables, sequtils, sets, algorithm, deques]
|
||||||
import chronos, chronicles, metrics
|
import chronos, chronicles, metrics
|
||||||
|
@ -33,7 +30,7 @@ declareGauge(libp2p_gossipsub_healthy_peers_topics, "number of topics in mesh wi
|
||||||
declareCounter(libp2p_gossipsub_above_dhigh_condition, "number of above dhigh pruning branches ran", labels = ["topic"])
|
declareCounter(libp2p_gossipsub_above_dhigh_condition, "number of above dhigh pruning branches ran", labels = ["topic"])
|
||||||
declareGauge(libp2p_gossipsub_received_iwants, "received iwants", labels = ["kind"])
|
declareGauge(libp2p_gossipsub_received_iwants, "received iwants", labels = ["kind"])
|
||||||
|
|
||||||
proc grafted*(g: GossipSub, p: PubSubPeer, topic: string) {.raises: [Defect].} =
|
proc grafted*(g: GossipSub, p: PubSubPeer, topic: string) {.raises: [].} =
|
||||||
g.withPeerStats(p.peerId) do (stats: var PeerStats):
|
g.withPeerStats(p.peerId) do (stats: var PeerStats):
|
||||||
var info = stats.topicInfos.getOrDefault(topic)
|
var info = stats.topicInfos.getOrDefault(topic)
|
||||||
info.graftTime = Moment.now()
|
info.graftTime = Moment.now()
|
||||||
|
@ -49,7 +46,7 @@ proc pruned*(g: GossipSub,
|
||||||
p: PubSubPeer,
|
p: PubSubPeer,
|
||||||
topic: string,
|
topic: string,
|
||||||
setBackoff: bool = true,
|
setBackoff: bool = true,
|
||||||
backoff = none(Duration)) {.raises: [Defect].} =
|
backoff = none(Duration)) {.raises: [].} =
|
||||||
if setBackoff:
|
if setBackoff:
|
||||||
let
|
let
|
||||||
backoffDuration =
|
backoffDuration =
|
||||||
|
@ -75,7 +72,7 @@ proc pruned*(g: GossipSub,
|
||||||
|
|
||||||
trace "pruned", peer=p, topic
|
trace "pruned", peer=p, topic
|
||||||
|
|
||||||
proc handleBackingOff*(t: var BackoffTable, topic: string) {.raises: [Defect].} =
|
proc handleBackingOff*(t: var BackoffTable, topic: string) {.raises: [].} =
|
||||||
let now = Moment.now()
|
let now = Moment.now()
|
||||||
var expired = toSeq(t.getOrDefault(topic).pairs())
|
var expired = toSeq(t.getOrDefault(topic).pairs())
|
||||||
expired.keepIf do (pair: tuple[peer: PeerId, expire: Moment]) -> bool:
|
expired.keepIf do (pair: tuple[peer: PeerId, expire: Moment]) -> bool:
|
||||||
|
@ -84,7 +81,7 @@ proc handleBackingOff*(t: var BackoffTable, topic: string) {.raises: [Defect].}
|
||||||
t.withValue(topic, v):
|
t.withValue(topic, v):
|
||||||
v[].del(peer)
|
v[].del(peer)
|
||||||
|
|
||||||
proc peerExchangeList*(g: GossipSub, topic: string): seq[PeerInfoMsg] {.raises: [Defect].} =
|
proc peerExchangeList*(g: GossipSub, topic: string): seq[PeerInfoMsg] {.raises: [].} =
|
||||||
if not g.parameters.enablePX:
|
if not g.parameters.enablePX:
|
||||||
return @[]
|
return @[]
|
||||||
var peers = g.gossipsub.getOrDefault(topic, initHashSet[PubSubPeer]()).toSeq()
|
var peers = g.gossipsub.getOrDefault(topic, initHashSet[PubSubPeer]()).toSeq()
|
||||||
|
@ -214,7 +211,7 @@ proc getPeers(prune: ControlPrune, peer: PubSubPeer): seq[(PeerId, Option[PeerRe
|
||||||
routingRecords
|
routingRecords
|
||||||
|
|
||||||
|
|
||||||
proc handlePrune*(g: GossipSub, peer: PubSubPeer, prunes: seq[ControlPrune]) {.raises: [Defect].} =
|
proc handlePrune*(g: GossipSub, peer: PubSubPeer, prunes: seq[ControlPrune]) {.raises: [].} =
|
||||||
for prune in prunes:
|
for prune in prunes:
|
||||||
let topic = prune.topicId
|
let topic = prune.topicId
|
||||||
|
|
||||||
|
@ -248,7 +245,7 @@ proc handlePrune*(g: GossipSub, peer: PubSubPeer, prunes: seq[ControlPrune]) {.r
|
||||||
|
|
||||||
proc handleIHave*(g: GossipSub,
|
proc handleIHave*(g: GossipSub,
|
||||||
peer: PubSubPeer,
|
peer: PubSubPeer,
|
||||||
ihaves: seq[ControlIHave]): ControlIWant {.raises: [Defect].} =
|
ihaves: seq[ControlIHave]): ControlIWant {.raises: [].} =
|
||||||
var res: ControlIWant
|
var res: ControlIWant
|
||||||
if peer.score < g.parameters.gossipThreshold:
|
if peer.score < g.parameters.gossipThreshold:
|
||||||
trace "ihave: ignoring low score peer", peer, score = peer.score
|
trace "ihave: ignoring low score peer", peer, score = peer.score
|
||||||
|
@ -280,7 +277,7 @@ proc handleIHave*(g: GossipSub,
|
||||||
|
|
||||||
proc handleIWant*(g: GossipSub,
|
proc handleIWant*(g: GossipSub,
|
||||||
peer: PubSubPeer,
|
peer: PubSubPeer,
|
||||||
iwants: seq[ControlIWant]): seq[Message] {.raises: [Defect].} =
|
iwants: seq[ControlIWant]): seq[Message] {.raises: [].} =
|
||||||
var
|
var
|
||||||
messages: seq[Message]
|
messages: seq[Message]
|
||||||
invalidRequests = 0
|
invalidRequests = 0
|
||||||
|
@ -307,7 +304,7 @@ proc handleIWant*(g: GossipSub,
|
||||||
libp2p_gossipsub_received_iwants.inc(1, labelValues=["unknown"])
|
libp2p_gossipsub_received_iwants.inc(1, labelValues=["unknown"])
|
||||||
return messages
|
return messages
|
||||||
|
|
||||||
proc commitMetrics(metrics: var MeshMetrics) {.raises: [Defect].} =
|
proc commitMetrics(metrics: var MeshMetrics) {.raises: [].} =
|
||||||
libp2p_gossipsub_low_peers_topics.set(metrics.lowPeersTopics)
|
libp2p_gossipsub_low_peers_topics.set(metrics.lowPeersTopics)
|
||||||
libp2p_gossipsub_no_peers_topics.set(metrics.noPeersTopics)
|
libp2p_gossipsub_no_peers_topics.set(metrics.noPeersTopics)
|
||||||
libp2p_gossipsub_under_dout_topics.set(metrics.underDoutTopics)
|
libp2p_gossipsub_under_dout_topics.set(metrics.underDoutTopics)
|
||||||
|
@ -316,7 +313,7 @@ proc commitMetrics(metrics: var MeshMetrics) {.raises: [Defect].} =
|
||||||
libp2p_gossipsub_peers_per_topic_fanout.set(metrics.otherPeersPerTopicFanout, labelValues = ["other"])
|
libp2p_gossipsub_peers_per_topic_fanout.set(metrics.otherPeersPerTopicFanout, labelValues = ["other"])
|
||||||
libp2p_gossipsub_peers_per_topic_mesh.set(metrics.otherPeersPerTopicMesh, labelValues = ["other"])
|
libp2p_gossipsub_peers_per_topic_mesh.set(metrics.otherPeersPerTopicMesh, labelValues = ["other"])
|
||||||
|
|
||||||
proc rebalanceMesh*(g: GossipSub, topic: string, metrics: ptr MeshMetrics = nil) {.raises: [Defect].} =
|
proc rebalanceMesh*(g: GossipSub, topic: string, metrics: ptr MeshMetrics = nil) {.raises: [].} =
|
||||||
logScope:
|
logScope:
|
||||||
topic
|
topic
|
||||||
mesh = g.mesh.peers(topic)
|
mesh = g.mesh.peers(topic)
|
||||||
|
@ -546,7 +543,7 @@ proc rebalanceMesh*(g: GossipSub, topic: string, metrics: ptr MeshMetrics = nil)
|
||||||
backoff: g.parameters.pruneBackoff.seconds.uint64)])))
|
backoff: g.parameters.pruneBackoff.seconds.uint64)])))
|
||||||
g.broadcast(prunes, prune)
|
g.broadcast(prunes, prune)
|
||||||
|
|
||||||
proc dropFanoutPeers*(g: GossipSub) {.raises: [Defect].} =
|
proc dropFanoutPeers*(g: GossipSub) {.raises: [].} =
|
||||||
# drop peers that we haven't published to in
|
# drop peers that we haven't published to in
|
||||||
# GossipSubFanoutTTL seconds
|
# GossipSubFanoutTTL seconds
|
||||||
let now = Moment.now()
|
let now = Moment.now()
|
||||||
|
@ -559,7 +556,7 @@ proc dropFanoutPeers*(g: GossipSub) {.raises: [Defect].} =
|
||||||
for topic in drops:
|
for topic in drops:
|
||||||
g.lastFanoutPubSub.del topic
|
g.lastFanoutPubSub.del topic
|
||||||
|
|
||||||
proc replenishFanout*(g: GossipSub, topic: string) {.raises: [Defect].} =
|
proc replenishFanout*(g: GossipSub, topic: string) {.raises: [].} =
|
||||||
## get fanout peers for a topic
|
## get fanout peers for a topic
|
||||||
logScope: topic
|
logScope: topic
|
||||||
trace "about to replenish fanout"
|
trace "about to replenish fanout"
|
||||||
|
@ -575,7 +572,7 @@ proc replenishFanout*(g: GossipSub, topic: string) {.raises: [Defect].} =
|
||||||
|
|
||||||
trace "fanout replenished with peers", peers = g.fanout.peers(topic)
|
trace "fanout replenished with peers", peers = g.fanout.peers(topic)
|
||||||
|
|
||||||
proc getGossipPeers*(g: GossipSub): Table[PubSubPeer, ControlMessage] {.raises: [Defect].} =
|
proc getGossipPeers*(g: GossipSub): Table[PubSubPeer, ControlMessage] {.raises: [].} =
|
||||||
## gossip iHave messages to peers
|
## gossip iHave messages to peers
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@ -638,7 +635,7 @@ proc getGossipPeers*(g: GossipSub): Table[PubSubPeer, ControlMessage] {.raises:
|
||||||
|
|
||||||
return control
|
return control
|
||||||
|
|
||||||
proc onHeartbeat(g: GossipSub) {.raises: [Defect].} =
|
proc onHeartbeat(g: GossipSub) {.raises: [].} =
|
||||||
# reset IWANT budget
|
# reset IWANT budget
|
||||||
# reset IHAVE cap
|
# reset IHAVE cap
|
||||||
block:
|
block:
|
||||||
|
@ -698,7 +695,7 @@ proc onHeartbeat(g: GossipSub) {.raises: [Defect].} =
|
||||||
|
|
||||||
g.mcache.shift() # shift the cache
|
g.mcache.shift() # shift the cache
|
||||||
|
|
||||||
# {.pop.} # raises [Defect]
|
# {.pop.} # raises []
|
||||||
|
|
||||||
proc heartbeat*(g: GossipSub) {.async.} =
|
proc heartbeat*(g: GossipSub) {.async.} =
|
||||||
heartbeat "GossipSub", g.parameters.heartbeatInterval:
|
heartbeat "GossipSub", g.parameters.heartbeatInterval:
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[tables, sets, options]
|
import std/[tables, sets, options]
|
||||||
import chronos, chronicles, metrics
|
import chronos, chronicles, metrics
|
||||||
|
@ -55,7 +52,7 @@ proc init*(_: type[TopicParams]): TopicParams =
|
||||||
proc withPeerStats*(
|
proc withPeerStats*(
|
||||||
g: GossipSub,
|
g: GossipSub,
|
||||||
peerId: PeerId,
|
peerId: PeerId,
|
||||||
action: proc (stats: var PeerStats) {.gcsafe, raises: [Defect].}) =
|
action: proc (stats: var PeerStats) {.gcsafe, raises: [].}) =
|
||||||
## Add or update peer statistics for a particular peer id - the statistics
|
## Add or update peer statistics for a particular peer id - the statistics
|
||||||
## are retained across multiple connections until they expire
|
## are retained across multiple connections until they expire
|
||||||
g.peerStats.withValue(peerId, stats) do:
|
g.peerStats.withValue(peerId, stats) do:
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import chronos
|
import chronos
|
||||||
import std/[options, tables, sets]
|
import std/[options, tables, sets]
|
||||||
|
@ -152,7 +149,7 @@ type
|
||||||
proc(peer: PeerId,
|
proc(peer: PeerId,
|
||||||
tag: string, # For gossipsub, the topic
|
tag: string, # For gossipsub, the topic
|
||||||
peers: seq[RoutingRecordsPair])
|
peers: seq[RoutingRecordsPair])
|
||||||
{.gcsafe, raises: [Defect].}
|
{.gcsafe, raises: [].}
|
||||||
|
|
||||||
GossipSub* = ref object of FloodSub
|
GossipSub* = ref object of FloodSub
|
||||||
mesh*: PeerTable # peers that we send messages to when we are subscribed to the topic
|
mesh*: PeerTable # peers that we send messages to when we are subscribed to the topic
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[sets, tables, options]
|
import std/[sets, tables, options]
|
||||||
import rpc/[messages]
|
import rpc/[messages]
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[tables, sets, sequtils]
|
import std/[tables, sets, sequtils]
|
||||||
import ./pubsubpeer, ../../peerid
|
import ./pubsubpeer, ../../peerid
|
||||||
|
|
|
@ -13,10 +13,7 @@
|
||||||
## `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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.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
|
||||||
|
@ -86,18 +83,18 @@ type
|
||||||
InitializationError* = object of LPError
|
InitializationError* = object of LPError
|
||||||
|
|
||||||
TopicHandler* {.public.} = proc(topic: string,
|
TopicHandler* {.public.} = proc(topic: string,
|
||||||
data: seq[byte]): Future[void] {.gcsafe, raises: [Defect].}
|
data: seq[byte]): Future[void] {.gcsafe, raises: [].}
|
||||||
|
|
||||||
ValidatorHandler* {.public.} = proc(topic: string,
|
ValidatorHandler* {.public.} = proc(topic: string,
|
||||||
message: Message): Future[ValidationResult] {.gcsafe, raises: [Defect].}
|
message: Message): Future[ValidationResult] {.gcsafe, raises: [].}
|
||||||
|
|
||||||
TopicPair* = tuple[topic: string, handler: TopicHandler]
|
TopicPair* = tuple[topic: string, handler: TopicHandler]
|
||||||
|
|
||||||
MsgIdProvider* {.public.} =
|
MsgIdProvider* {.public.} =
|
||||||
proc(m: Message): Result[MessageId, ValidationResult] {.noSideEffect, raises: [Defect], gcsafe.}
|
proc(m: Message): Result[MessageId, ValidationResult] {.noSideEffect, raises: [], gcsafe.}
|
||||||
|
|
||||||
SubscriptionValidator* {.public.} =
|
SubscriptionValidator* {.public.} =
|
||||||
proc(topic: string): bool {.raises: [Defect], gcsafe.}
|
proc(topic: string): bool {.raises: [], gcsafe.}
|
||||||
## Every time a peer send us a subscription (even to an unknown topic),
|
## Every time a peer send us a subscription (even to an unknown topic),
|
||||||
## we have to store it, which may be an attack vector.
|
## we have to store it, which may be an attack vector.
|
||||||
## This callback can be used to reject topic we're not interested in
|
## This callback can be used to reject topic we're not interested in
|
||||||
|
@ -140,7 +137,7 @@ method unsubscribePeer*(p: PubSub, peerId: PeerId) {.base, gcsafe.} =
|
||||||
|
|
||||||
libp2p_pubsub_peers.set(p.peers.len.int64)
|
libp2p_pubsub_peers.set(p.peers.len.int64)
|
||||||
|
|
||||||
proc send*(p: PubSub, peer: PubSubPeer, msg: RPCMsg) {.raises: [Defect].} =
|
proc send*(p: PubSub, peer: PubSubPeer, msg: RPCMsg) {.raises: [].} =
|
||||||
## Attempt to send `msg` to remote peer
|
## Attempt to send `msg` to remote peer
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@ -150,7 +147,7 @@ proc send*(p: PubSub, peer: PubSubPeer, msg: RPCMsg) {.raises: [Defect].} =
|
||||||
proc broadcast*(
|
proc broadcast*(
|
||||||
p: PubSub,
|
p: PubSub,
|
||||||
sendPeers: auto, # Iteratble[PubSubPeer]
|
sendPeers: auto, # Iteratble[PubSubPeer]
|
||||||
msg: RPCMsg) {.raises: [Defect].} =
|
msg: RPCMsg) {.raises: [].} =
|
||||||
## Attempt to send `msg` to the given peers
|
## Attempt to send `msg` to the given peers
|
||||||
|
|
||||||
let npeers = sendPeers.len.int64
|
let npeers = sendPeers.len.int64
|
||||||
|
@ -491,7 +488,7 @@ method publish*(p: PubSub,
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
method initPubSub*(p: PubSub)
|
method initPubSub*(p: PubSub)
|
||||||
{.base, raises: [Defect, InitializationError].} =
|
{.base, raises: [InitializationError].} =
|
||||||
## perform pubsub initialization
|
## perform pubsub initialization
|
||||||
p.observers = new(seq[PubSubObserver])
|
p.observers = new(seq[PubSubObserver])
|
||||||
if p.msgIdProvider == nil:
|
if p.msgIdProvider == nil:
|
||||||
|
@ -559,7 +556,7 @@ proc init*[PubParams: object | bool](
|
||||||
maxMessageSize: int = 1024 * 1024,
|
maxMessageSize: int = 1024 * 1024,
|
||||||
rng: ref HmacDrbgContext = newRng(),
|
rng: ref HmacDrbgContext = newRng(),
|
||||||
parameters: PubParams = false): P
|
parameters: PubParams = false): P
|
||||||
{.raises: [Defect, InitializationError], public.} =
|
{.raises: [InitializationError], public.} =
|
||||||
let pubsub =
|
let pubsub =
|
||||||
when PubParams is bool:
|
when PubParams is bool:
|
||||||
P(switch: switch,
|
P(switch: switch,
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[sequtils, strutils, tables, hashes, options, sets, deques]
|
import std/[sequtils, strutils, tables, hashes, options, sets, deques]
|
||||||
import stew/results
|
import stew/results
|
||||||
|
@ -36,8 +33,8 @@ when defined(libp2p_expensive_metrics):
|
||||||
|
|
||||||
type
|
type
|
||||||
PubSubObserver* = ref object
|
PubSubObserver* = ref object
|
||||||
onRecv*: proc(peer: PubSubPeer; msgs: var RPCMsg) {.gcsafe, raises: [Defect].}
|
onRecv*: proc(peer: PubSubPeer; msgs: var RPCMsg) {.gcsafe, raises: [].}
|
||||||
onSend*: proc(peer: PubSubPeer; msgs: var RPCMsg) {.gcsafe, raises: [Defect].}
|
onSend*: proc(peer: PubSubPeer; msgs: var RPCMsg) {.gcsafe, raises: [].}
|
||||||
|
|
||||||
PubSubPeerEventKind* {.pure.} = enum
|
PubSubPeerEventKind* {.pure.} = enum
|
||||||
Connected
|
Connected
|
||||||
|
@ -46,9 +43,9 @@ type
|
||||||
PubSubPeerEvent* = object
|
PubSubPeerEvent* = object
|
||||||
kind*: PubSubPeerEventKind
|
kind*: PubSubPeerEventKind
|
||||||
|
|
||||||
GetConn* = proc(): Future[Connection] {.gcsafe, raises: [Defect].}
|
GetConn* = proc(): Future[Connection] {.gcsafe, raises: [].}
|
||||||
DropConn* = proc(peer: PubSubPeer) {.gcsafe, raises: [Defect].} # have to pass peer as it's unknown during init
|
DropConn* = proc(peer: PubSubPeer) {.gcsafe, raises: [].} # have to pass peer as it's unknown during init
|
||||||
OnEvent* = proc(peer: PubSubPeer, event: PubSubPeerEvent) {.gcsafe, raises: [Defect].}
|
OnEvent* = proc(peer: PubSubPeer, event: PubSubPeerEvent) {.gcsafe, raises: [].}
|
||||||
|
|
||||||
PubSubPeer* = ref object of RootObj
|
PubSubPeer* = ref object of RootObj
|
||||||
getConn*: GetConn # callback to establish a new send connection
|
getConn*: GetConn # callback to establish a new send connection
|
||||||
|
@ -69,7 +66,7 @@ type
|
||||||
behaviourPenalty*: float64 # the eventual penalty score
|
behaviourPenalty*: float64 # the eventual penalty score
|
||||||
|
|
||||||
RPCHandler* = proc(peer: PubSubPeer, msg: RPCMsg): Future[void]
|
RPCHandler* = proc(peer: PubSubPeer, msg: RPCMsg): Future[void]
|
||||||
{.gcsafe, raises: [Defect].}
|
{.gcsafe, raises: [].}
|
||||||
|
|
||||||
when defined(libp2p_agents_metrics):
|
when defined(libp2p_agents_metrics):
|
||||||
func shortAgent*(p: PubSubPeer): string =
|
func shortAgent*(p: PubSubPeer): string =
|
||||||
|
@ -237,7 +234,7 @@ template sendMetrics(msg: RPCMsg): untyped =
|
||||||
# metrics
|
# metrics
|
||||||
libp2p_pubsub_sent_messages.inc(labelValues = [$p.peerId, t])
|
libp2p_pubsub_sent_messages.inc(labelValues = [$p.peerId, t])
|
||||||
|
|
||||||
proc sendEncoded*(p: PubSubPeer, msg: seq[byte]) {.raises: [Defect], async.} =
|
proc sendEncoded*(p: PubSubPeer, msg: seq[byte]) {.raises: [], async.} =
|
||||||
doAssert(not isNil(p), "pubsubpeer nil!")
|
doAssert(not isNil(p), "pubsubpeer nil!")
|
||||||
|
|
||||||
if msg.len <= 0:
|
if msg.len <= 0:
|
||||||
|
@ -270,7 +267,7 @@ proc sendEncoded*(p: PubSubPeer, msg: seq[byte]) {.raises: [Defect], async.} =
|
||||||
|
|
||||||
await conn.close() # This will clean up the send connection
|
await conn.close() # This will clean up the send connection
|
||||||
|
|
||||||
proc send*(p: PubSubPeer, msg: RPCMsg, anonymize: bool) {.raises: [Defect].} =
|
proc send*(p: PubSubPeer, msg: RPCMsg, anonymize: bool) {.raises: [].} =
|
||||||
trace "sending msg to peer", peer = p, rpcMsg = shortLog(msg)
|
trace "sending msg to peer", peer = p, rpcMsg = shortLog(msg)
|
||||||
|
|
||||||
# When sending messages, we take care to re-encode them with the right
|
# When sending messages, we take care to re-encode them with the right
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import chronicles, metrics, stew/[byteutils, endians2]
|
import chronicles, metrics, stew/[byteutils, endians2]
|
||||||
import ./messages,
|
import ./messages,
|
||||||
|
@ -65,7 +62,7 @@ proc init*(
|
||||||
topic: string,
|
topic: string,
|
||||||
seqno: Option[uint64],
|
seqno: Option[uint64],
|
||||||
sign: bool = true): Message
|
sign: bool = true): Message
|
||||||
{.gcsafe, raises: [Defect, LPError].} =
|
{.gcsafe, raises: [LPError].} =
|
||||||
var msg = Message(data: data, topicIDs: @[topic])
|
var msg = Message(data: data, topicIDs: @[topic])
|
||||||
|
|
||||||
# order matters, we want to include seqno in the signature
|
# order matters, we want to include seqno in the signature
|
||||||
|
@ -90,7 +87,7 @@ proc init*(
|
||||||
data: seq[byte],
|
data: seq[byte],
|
||||||
topic: string,
|
topic: string,
|
||||||
seqno: Option[uint64]): Message
|
seqno: Option[uint64]): Message
|
||||||
{.gcsafe, raises: [Defect, LPError].} =
|
{.gcsafe, raises: [LPError].} =
|
||||||
var msg = Message(data: data, topicIDs: @[topic])
|
var msg = Message(data: data, topicIDs: @[topic])
|
||||||
msg.fromPeer = peerId
|
msg.fromPeer = peerId
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import options, sequtils
|
import options, sequtils
|
||||||
import "../../.."/[
|
import "../../.."/[
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import options
|
import options
|
||||||
import stew/assign2
|
import stew/assign2
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[tables]
|
import std/[tables]
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import tables, sequtils, sugar, sets, options
|
import tables, sequtils, sugar, sets, options
|
||||||
import chronos,
|
import chronos,
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/strformat
|
import std/strformat
|
||||||
import chronos
|
import chronos
|
||||||
|
@ -136,7 +133,7 @@ proc encrypt(
|
||||||
state: var CipherState,
|
state: var CipherState,
|
||||||
data: var openArray[byte],
|
data: var openArray[byte],
|
||||||
ad: openArray[byte]): ChaChaPolyTag
|
ad: openArray[byte]): ChaChaPolyTag
|
||||||
{.noinit, raises: [Defect, NoiseNonceMaxError].} =
|
{.noinit, raises: [NoiseNonceMaxError].} =
|
||||||
|
|
||||||
var nonce: ChaChaPolyNonce
|
var nonce: ChaChaPolyNonce
|
||||||
nonce[4..<12] = toBytesLE(state.n)
|
nonce[4..<12] = toBytesLE(state.n)
|
||||||
|
@ -148,7 +145,7 @@ proc encrypt(
|
||||||
raise newException(NoiseNonceMaxError, "Noise max nonce value reached")
|
raise newException(NoiseNonceMaxError, "Noise max nonce value reached")
|
||||||
|
|
||||||
proc encryptWithAd(state: var CipherState, ad, data: openArray[byte]): seq[byte]
|
proc encryptWithAd(state: var CipherState, ad, data: openArray[byte]): seq[byte]
|
||||||
{.raises: [Defect, NoiseNonceMaxError].} =
|
{.raises: [NoiseNonceMaxError].} =
|
||||||
result = newSeqOfCap[byte](data.len + sizeof(ChaChaPolyTag))
|
result = newSeqOfCap[byte](data.len + sizeof(ChaChaPolyTag))
|
||||||
result.add(data)
|
result.add(data)
|
||||||
|
|
||||||
|
@ -160,7 +157,7 @@ proc encryptWithAd(state: var CipherState, ad, data: openArray[byte]): seq[byte]
|
||||||
tag = byteutils.toHex(tag), data = result.shortLog, nonce = state.n - 1
|
tag = byteutils.toHex(tag), data = result.shortLog, nonce = state.n - 1
|
||||||
|
|
||||||
proc decryptWithAd(state: var CipherState, ad, data: openArray[byte]): seq[byte]
|
proc decryptWithAd(state: var CipherState, ad, data: openArray[byte]): seq[byte]
|
||||||
{.raises: [Defect, NoiseDecryptTagError, NoiseNonceMaxError].} =
|
{.raises: [NoiseDecryptTagError, NoiseNonceMaxError].} =
|
||||||
var
|
var
|
||||||
tagIn = data.toOpenArray(data.len - ChaChaPolyTag.len, data.high).intoChaChaPolyTag
|
tagIn = data.toOpenArray(data.len - ChaChaPolyTag.len, data.high).intoChaChaPolyTag
|
||||||
tagOut: ChaChaPolyTag
|
tagOut: ChaChaPolyTag
|
||||||
|
@ -209,7 +206,7 @@ proc mixKeyAndHash(ss: var SymmetricState, ikm: openArray[byte]) {.used.} =
|
||||||
ss.cs = CipherState(k: temp_keys[2])
|
ss.cs = CipherState(k: temp_keys[2])
|
||||||
|
|
||||||
proc encryptAndHash(ss: var SymmetricState, data: openArray[byte]): seq[byte]
|
proc encryptAndHash(ss: var SymmetricState, data: openArray[byte]): seq[byte]
|
||||||
{.raises: [Defect, NoiseNonceMaxError].} =
|
{.raises: [NoiseNonceMaxError].} =
|
||||||
# according to spec if key is empty leave plaintext
|
# according to spec if key is empty leave plaintext
|
||||||
if ss.cs.hasKey:
|
if ss.cs.hasKey:
|
||||||
result = ss.cs.encryptWithAd(ss.h.data, data)
|
result = ss.cs.encryptWithAd(ss.h.data, data)
|
||||||
|
@ -218,7 +215,7 @@ proc encryptAndHash(ss: var SymmetricState, data: openArray[byte]): seq[byte]
|
||||||
ss.mixHash(result)
|
ss.mixHash(result)
|
||||||
|
|
||||||
proc decryptAndHash(ss: var SymmetricState, data: openArray[byte]): seq[byte]
|
proc decryptAndHash(ss: var SymmetricState, data: openArray[byte]): seq[byte]
|
||||||
{.raises: [Defect, NoiseDecryptTagError, NoiseNonceMaxError].} =
|
{.raises: [NoiseDecryptTagError, NoiseNonceMaxError].} =
|
||||||
# according to spec if key is empty leave plaintext
|
# according to spec if key is empty leave plaintext
|
||||||
if ss.cs.hasKey and data.len > ChaChaPolyTag.len:
|
if ss.cs.hasKey and data.len > ChaChaPolyTag.len:
|
||||||
result = ss.cs.decryptWithAd(ss.h.data, data)
|
result = ss.cs.decryptWithAd(ss.h.data, data)
|
||||||
|
@ -448,7 +445,7 @@ proc encryptFrame(
|
||||||
sconn: NoiseConnection,
|
sconn: NoiseConnection,
|
||||||
cipherFrame: var openArray[byte],
|
cipherFrame: var openArray[byte],
|
||||||
src: openArray[byte])
|
src: openArray[byte])
|
||||||
{.raises: [Defect, NoiseNonceMaxError].} =
|
{.raises: [NoiseNonceMaxError].} =
|
||||||
# Frame consists of length + cipher data + tag
|
# Frame consists of length + cipher data + tag
|
||||||
doAssert src.len <= MaxPlainSize
|
doAssert src.len <= MaxPlainSize
|
||||||
doAssert cipherFrame.len == 2 + src.len + sizeof(ChaChaPolyTag)
|
doAssert cipherFrame.len == 2 + src.len + sizeof(ChaChaPolyTag)
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import chronos
|
import chronos
|
||||||
import secure, ../../stream/connection
|
import secure, ../../stream/connection
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[oids, strformat]
|
import std/[oids, strformat]
|
||||||
import bearssl/rand
|
import bearssl/rand
|
||||||
|
@ -262,7 +259,7 @@ proc newSecioConn(conn: Connection,
|
||||||
secrets: Secret,
|
secrets: Secret,
|
||||||
order: int,
|
order: int,
|
||||||
remotePubKey: PublicKey): SecioConn
|
remotePubKey: PublicKey): SecioConn
|
||||||
{.raises: [Defect, LPError].} =
|
{.raises: [LPError].} =
|
||||||
## Create new secure stream/lpstream, using specified hash algorithm ``hash``,
|
## Create new secure stream/lpstream, using specified hash algorithm ``hash``,
|
||||||
## cipher algorithm ``cipher``, stretched keys ``secrets`` and order
|
## cipher algorithm ``cipher``, stretched keys ``secrets`` and order
|
||||||
## ``order``.
|
## ``order``.
|
||||||
|
|
|
@ -8,10 +8,7 @@
|
||||||
# those terms.
|
# those terms.
|
||||||
|
|
||||||
{.push gcsafe.}
|
{.push gcsafe.}
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[strformat]
|
import std/[strformat]
|
||||||
import stew/results
|
import stew/results
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
|
|
||||||
## This module implements Routing Records.
|
## This module implements Routing Records.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[sequtils, times]
|
import std/[sequtils, times]
|
||||||
import pkg/stew/results
|
import pkg/stew/results
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import chronos, chronicles, times, tables, sequtils
|
import chronos, chronicles, times, tables, sequtils
|
||||||
import ../switch,
|
import ../switch,
|
||||||
|
@ -20,7 +17,7 @@ logScope:
|
||||||
topics = "libp2p autorelay"
|
topics = "libp2p autorelay"
|
||||||
|
|
||||||
type
|
type
|
||||||
OnReservationHandler = proc (addresses: seq[MultiAddress]) {.gcsafe, raises: [Defect].}
|
OnReservationHandler = proc (addresses: seq[MultiAddress]) {.gcsafe, raises: [].}
|
||||||
|
|
||||||
AutoRelayService* = ref object of Service
|
AutoRelayService* = ref object of Service
|
||||||
running: bool
|
running: bool
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[tables, sequtils]
|
import std/[tables, sequtils]
|
||||||
|
|
||||||
|
@ -35,7 +32,7 @@ type
|
||||||
autonatService: AutonatService
|
autonatService: AutonatService
|
||||||
isPublicIPAddrProc: IsPublicIPAddrProc
|
isPublicIPAddrProc: IsPublicIPAddrProc
|
||||||
|
|
||||||
IsPublicIPAddrProc* = proc(ta: TransportAddress): bool {.gcsafe, raises: [Defect].}
|
IsPublicIPAddrProc* = proc(ta: TransportAddress): bool {.gcsafe, raises: [].}
|
||||||
|
|
||||||
proc new*(T: typedesc[HPService], autonatService: AutonatService, autoRelayService: AutoRelayService,
|
proc new*(T: typedesc[HPService], autonatService: AutonatService, autoRelayService: AutoRelayService,
|
||||||
isPublicIPAddrProc: IsPublicIPAddrProc = isGlobal): T =
|
isPublicIPAddrProc: IsPublicIPAddrProc = isGlobal): T =
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
|
|
||||||
## This module implements Signed Envelope.
|
## This module implements Signed Envelope.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/sugar
|
import std/sugar
|
||||||
import pkg/stew/[results, byteutils]
|
import pkg/stew/[results, byteutils]
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/strformat
|
import std/strformat
|
||||||
import stew/byteutils
|
import stew/byteutils
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[strformat]
|
import std/[strformat]
|
||||||
import stew/results
|
import stew/results
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[hashes, oids, strformat]
|
import std/[hashes, oids, strformat]
|
||||||
import stew/results
|
import stew/results
|
||||||
|
@ -30,7 +27,7 @@ const
|
||||||
DefaultConnectionTimeout* = 5.minutes
|
DefaultConnectionTimeout* = 5.minutes
|
||||||
|
|
||||||
type
|
type
|
||||||
TimeoutHandler* = proc(): Future[void] {.gcsafe, raises: [Defect].}
|
TimeoutHandler* = proc(): Future[void] {.gcsafe, raises: [].}
|
||||||
|
|
||||||
Connection* = ref object of LPStream
|
Connection* = ref object of LPStream
|
||||||
activity*: bool # reset every time data is sent or received
|
activity*: bool # reset every time data is sent or received
|
||||||
|
|
|
@ -10,10 +10,7 @@
|
||||||
## Length Prefixed stream implementation
|
## Length Prefixed stream implementation
|
||||||
|
|
||||||
{.push gcsafe.}
|
{.push gcsafe.}
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/oids
|
import std/oids
|
||||||
import stew/byteutils
|
import stew/byteutils
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
# Nim-LibP2P
|
||||||
{.push raises: [Defect].}
|
# Copyright (c) 2023 Status Research & Development GmbH
|
||||||
else:
|
# Licensed under either of
|
||||||
{.push raises: [].}
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
||||||
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
||||||
|
# at your option.
|
||||||
|
# This file may not be copied, modified, or distributed except according to
|
||||||
|
# those terms.
|
||||||
|
|
||||||
|
{.push raises: [].}
|
||||||
|
|
||||||
import stew/bitops2
|
import stew/bitops2
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,7 @@
|
||||||
## 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
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[tables,
|
import std/[tables,
|
||||||
options,
|
options,
|
||||||
|
@ -198,7 +195,7 @@ proc dial*(
|
||||||
dial(s, peerId, addrs, @[proto])
|
dial(s, peerId, addrs, @[proto])
|
||||||
|
|
||||||
proc mount*[T: LPProtocol](s: Switch, proto: T, matcher: Matcher = nil)
|
proc mount*[T: LPProtocol](s: Switch, proto: T, matcher: Matcher = nil)
|
||||||
{.gcsafe, raises: [Defect, LPError], public.} =
|
{.gcsafe, raises: [LPError], public.} =
|
||||||
## mount a protocol to the switch
|
## mount a protocol to the switch
|
||||||
|
|
||||||
if isNil(proto.handler):
|
if isNil(proto.handler):
|
||||||
|
@ -380,7 +377,7 @@ proc newSwitch*(peerInfo: PeerInfo,
|
||||||
peerStore: PeerStore,
|
peerStore: PeerStore,
|
||||||
nameResolver: NameResolver = nil,
|
nameResolver: NameResolver = nil,
|
||||||
services = newSeq[Service]()): Switch
|
services = newSeq[Service]()): Switch
|
||||||
{.raises: [Defect, LPError].} =
|
{.raises: [LPError].} =
|
||||||
if secureManagers.len == 0:
|
if secureManagers.len == 0:
|
||||||
raise newException(LPError, "Provide at least one secure manager")
|
raise newException(LPError, "Provide at least one secure manager")
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import vbuffer
|
||||||
type
|
type
|
||||||
Transcoder* = object
|
Transcoder* = object
|
||||||
stringToBuffer*: proc(s: string,
|
stringToBuffer*: proc(s: string,
|
||||||
vb: var VBuffer): bool {.nimcall, gcsafe, noSideEffect, raises: [Defect].}
|
vb: var VBuffer): bool {.nimcall, gcsafe, noSideEffect, raises: [].}
|
||||||
bufferToString*: proc(vb: var VBuffer,
|
bufferToString*: proc(vb: var VBuffer,
|
||||||
s: var string): bool {.nimcall, gcsafe, noSideEffect, raises: [Defect].}
|
s: var string): bool {.nimcall, gcsafe, noSideEffect, raises: [].}
|
||||||
validateBuffer*: proc(vb: var VBuffer): bool {.nimcall, gcsafe, noSideEffect, raises: [Defect].}
|
validateBuffer*: proc(vb: var VBuffer): bool {.nimcall, gcsafe, noSideEffect, raises: [].}
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
|
|
||||||
## TCP transport implementation
|
## TCP transport implementation
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[sequtils]
|
import std/[sequtils]
|
||||||
import stew/results
|
import stew/results
|
||||||
|
@ -50,7 +47,7 @@ type
|
||||||
|
|
||||||
TcpTransportError* = object of transport.TransportError
|
TcpTransportError* = object of transport.TransportError
|
||||||
|
|
||||||
proc setupTcpTransportTracker(): TcpTransportTracker {.gcsafe, raises: [Defect].}
|
proc setupTcpTransportTracker(): TcpTransportTracker {.gcsafe, raises: [].}
|
||||||
|
|
||||||
proc getTcpTransportTracker(): TcpTransportTracker {.gcsafe.} =
|
proc getTcpTransportTracker(): TcpTransportTracker {.gcsafe.} =
|
||||||
result = cast[TcpTransportTracker](getTracker(TcpTransportTrackerName))
|
result = cast[TcpTransportTracker](getTracker(TcpTransportTrackerName))
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
|
|
||||||
## Tor transport implementation
|
## Tor transport implementation
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/strformat
|
import std/strformat
|
||||||
import chronos, chronicles, strutils
|
import chronos, chronicles, strutils
|
||||||
|
@ -133,7 +130,7 @@ proc readServerReply(transp: StreamTransport) {.async, gcsafe.} =
|
||||||
else:
|
else:
|
||||||
raise newException(LPError, "Address not supported")
|
raise newException(LPError, "Address not supported")
|
||||||
|
|
||||||
proc parseOnion3(address: MultiAddress): (byte, seq[byte], seq[byte]) {.raises: [Defect, LPError, ValueError].} =
|
proc parseOnion3(address: MultiAddress): (byte, seq[byte], seq[byte]) {.raises: [LPError, ValueError].} =
|
||||||
var addressArray = ($address).split('/')
|
var addressArray = ($address).split('/')
|
||||||
if addressArray.len < 2: raise newException(LPError, fmt"Onion address not supported {address}")
|
if addressArray.len < 2: raise newException(LPError, fmt"Onion address not supported {address}")
|
||||||
addressArray = addressArray[2].split(':')
|
addressArray = addressArray[2].split(':')
|
||||||
|
@ -144,7 +141,7 @@ proc parseOnion3(address: MultiAddress): (byte, seq[byte], seq[byte]) {.raises:
|
||||||
dstPort = address.data.buffer[37..38]
|
dstPort = address.data.buffer[37..38]
|
||||||
return (Socks5AddressType.FQDN.byte, dstAddr, dstPort)
|
return (Socks5AddressType.FQDN.byte, dstAddr, dstPort)
|
||||||
|
|
||||||
proc parseIpTcp(address: MultiAddress): (byte, seq[byte], seq[byte]) {.raises: [Defect, LPError, ValueError].} =
|
proc parseIpTcp(address: MultiAddress): (byte, seq[byte], seq[byte]) {.raises: [LPError, ValueError].} =
|
||||||
let (codec, atyp) =
|
let (codec, atyp) =
|
||||||
if IPv4Tcp.match(address):
|
if IPv4Tcp.match(address):
|
||||||
(multiCodec("ip4"), Socks5AddressType.IPv4.byte)
|
(multiCodec("ip4"), Socks5AddressType.IPv4.byte)
|
||||||
|
@ -254,7 +251,7 @@ proc new*(
|
||||||
rng: ref HmacDrbgContext,
|
rng: ref HmacDrbgContext,
|
||||||
addresses: seq[MultiAddress] = @[],
|
addresses: seq[MultiAddress] = @[],
|
||||||
flags: set[ServerFlags] = {}): TorSwitch
|
flags: set[ServerFlags] = {}): TorSwitch
|
||||||
{.raises: [LPError, Defect], public.} =
|
{.raises: [LPError], public.} =
|
||||||
var builder = SwitchBuilder.new()
|
var builder = SwitchBuilder.new()
|
||||||
.withRng(rng)
|
.withRng(rng)
|
||||||
.withTransport(proc(upgr: Upgrade): Transport = TorTransport.new(torServer, flags, upgr))
|
.withTransport(proc(upgr: Upgrade): Transport = TorTransport.new(torServer, flags, upgr))
|
||||||
|
|
|
@ -8,10 +8,7 @@
|
||||||
# those terms.
|
# those terms.
|
||||||
##
|
##
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import sequtils
|
import sequtils
|
||||||
import chronos, chronicles
|
import chronos, chronicles
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
|
|
||||||
## WebSocket & WebSocket Secure transport implementation
|
## WebSocket & WebSocket Secure transport implementation
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[sequtils]
|
import std/[sequtils]
|
||||||
import stew/results
|
import stew/results
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/sequtils
|
import std/sequtils
|
||||||
import pkg/[chronos, chronicles, metrics]
|
import pkg/[chronos, chronicles, metrics]
|
||||||
|
@ -104,7 +101,7 @@ proc new*(
|
||||||
ms: ms)
|
ms: ms)
|
||||||
|
|
||||||
upgrader.streamHandler = proc(conn: Connection)
|
upgrader.streamHandler = proc(conn: Connection)
|
||||||
{.async, gcsafe, raises: [Defect].} =
|
{.async, gcsafe, raises: [].} =
|
||||||
trace "Starting stream handler", conn
|
trace "Starting stream handler", conn
|
||||||
try:
|
try:
|
||||||
await upgrader.ms.handle(conn) # handle incoming connection
|
await upgrader.ms.handle(conn) # handle incoming connection
|
||||||
|
|
|
@ -8,10 +8,7 @@
|
||||||
# those terms.
|
# those terms.
|
||||||
|
|
||||||
{.push gcsafe.}
|
{.push gcsafe.}
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import std/[sequtils, strutils]
|
import std/[sequtils, strutils]
|
||||||
import pkg/[chronos, chronicles, metrics]
|
import pkg/[chronos, chronicles, metrics]
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import stew/byteutils
|
import stew/byteutils
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import chronos
|
import chronos
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import chronos, chronicles
|
import chronos, chronicles
|
||||||
|
|
||||||
|
|
|
@ -50,10 +50,7 @@ template flushIfIt*(o, pred: untyped) =
|
||||||
if not pred: break
|
if not pred: break
|
||||||
i.inc()
|
i.inc()
|
||||||
if i > 0:
|
if i > 0:
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
o.s.delete(0..<i)
|
||||||
o.s.delete(0, i - 1)
|
|
||||||
else:
|
|
||||||
o.s.delete(0..<i)
|
|
||||||
o.offset.inc(i)
|
o.offset.inc(i)
|
||||||
|
|
||||||
proc add*[T](o: var OffsettedSeq[T], v: T) =
|
proc add*[T](o: var OffsettedSeq[T], v: T) =
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import sequtils
|
import sequtils
|
||||||
import chronos, chronicles
|
import chronos, chronicles
|
||||||
|
|
|
@ -16,10 +16,7 @@
|
||||||
## 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
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import stew/[byteutils, leb128, results]
|
import stew/[byteutils, leb128, results]
|
||||||
export leb128, results
|
export leb128, results
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
|
|
||||||
## This module implements variable buffer.
|
## This module implements variable buffer.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.push raises: [Defect].}
|
|
||||||
else:
|
|
||||||
{.push raises: [].}
|
|
||||||
|
|
||||||
import varint, strutils
|
import varint, strutils
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
# 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.
|
||||||
|
|
||||||
when (NimMajor, NimMinor) < (1, 4):
|
{.push raises: [].}
|
||||||
{.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
|
||||||
|
@ -79,7 +76,7 @@ proc connect*(
|
||||||
child: StreamTransport = nil,
|
child: StreamTransport = nil,
|
||||||
flags = default(set[SocketFlags]),
|
flags = default(set[SocketFlags]),
|
||||||
localAddress: Opt[MultiAddress] = Opt.none(MultiAddress)): Future[StreamTransport]
|
localAddress: Opt[MultiAddress] = Opt.none(MultiAddress)): Future[StreamTransport]
|
||||||
{.raises: [Defect, LPError, MaInvalidAddress].} =
|
{.raises: [LPError, MaInvalidAddress].} =
|
||||||
## Open new connection to remote peer with address ``ma`` and create
|
## Open new connection to remote peer with address ``ma`` and create
|
||||||
## new transport object ``StreamTransport`` for established connection.
|
## new transport object ``StreamTransport`` for established connection.
|
||||||
## ``bufferSize`` is size of internal buffer for transport.
|
## ``bufferSize`` is size of internal buffer for transport.
|
||||||
|
@ -107,7 +104,7 @@ proc createStreamServer*[T](ma: MultiAddress,
|
||||||
bufferSize: int = DefaultStreamBufferSize,
|
bufferSize: int = DefaultStreamBufferSize,
|
||||||
child: StreamServer = nil,
|
child: StreamServer = nil,
|
||||||
init: TransportInitCallback = nil): StreamServer
|
init: TransportInitCallback = nil): StreamServer
|
||||||
{.raises: [Defect, LPError, MaInvalidAddress].} =
|
{.raises: [LPError, MaInvalidAddress].} =
|
||||||
## Create new TCP stream server which bounds to ``ma`` address.
|
## Create new TCP stream server which bounds to ``ma`` address.
|
||||||
if not(RTRANSPMA.match(ma)):
|
if not(RTRANSPMA.match(ma)):
|
||||||
raise newException(MaInvalidAddress, "Incorrect or unsupported address!")
|
raise newException(MaInvalidAddress, "Incorrect or unsupported address!")
|
||||||
|
@ -134,7 +131,7 @@ proc createStreamServer*[T](ma: MultiAddress,
|
||||||
bufferSize: int = DefaultStreamBufferSize,
|
bufferSize: int = DefaultStreamBufferSize,
|
||||||
child: StreamServer = nil,
|
child: StreamServer = nil,
|
||||||
init: TransportInitCallback = nil): StreamServer
|
init: TransportInitCallback = nil): StreamServer
|
||||||
{.raises: [Defect, LPError, MaInvalidAddress].} =
|
{.raises: [LPError, MaInvalidAddress].} =
|
||||||
## Create new TCP stream server which bounds to ``ma`` address.
|
## Create new TCP stream server which bounds to ``ma`` address.
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@ -155,7 +152,7 @@ proc createStreamServer*[T](ma: MultiAddress,
|
||||||
raise newException(LPError, exc.msg)
|
raise newException(LPError, exc.msg)
|
||||||
|
|
||||||
proc createAsyncSocket*(ma: MultiAddress): AsyncFD
|
proc createAsyncSocket*(ma: MultiAddress): AsyncFD
|
||||||
{.raises: [Defect, LPError].} =
|
{.raises: [LPError].} =
|
||||||
## Create new asynchronous socket using MultiAddress' ``ma`` socket type and
|
## Create new asynchronous socket using MultiAddress' ``ma`` socket type and
|
||||||
## protocol information.
|
## protocol information.
|
||||||
##
|
##
|
||||||
|
@ -188,7 +185,7 @@ proc createAsyncSocket*(ma: MultiAddress): AsyncFD
|
||||||
raise newException(LPError, exc.msg)
|
raise newException(LPError, exc.msg)
|
||||||
|
|
||||||
proc bindAsyncSocket*(sock: AsyncFD, ma: MultiAddress): bool
|
proc bindAsyncSocket*(sock: AsyncFD, ma: MultiAddress): bool
|
||||||
{.raises: [Defect, LPError].} =
|
{.raises: [LPError].} =
|
||||||
## Bind socket ``sock`` to MultiAddress ``ma``.
|
## Bind socket ``sock`` to MultiAddress ``ma``.
|
||||||
##
|
##
|
||||||
## Note: This procedure only used in `go-libp2p-daemon` wrapper.
|
## Note: This procedure only used in `go-libp2p-daemon` wrapper.
|
||||||
|
|
|
@ -10,7 +10,7 @@ type
|
||||||
ma: MultiAddress = MultiAddress.init("/ip4/127.0.0.1/tcp/0").tryGet(),
|
ma: MultiAddress = MultiAddress.init("/ip4/127.0.0.1/tcp/0").tryGet(),
|
||||||
prov: TransportProvider = proc(upgr: Upgrade): Transport = TcpTransport.new({}, upgr),
|
prov: TransportProvider = proc(upgr: Upgrade): Transport = TcpTransport.new({}, upgr),
|
||||||
relay: Relay = Relay.new(circuitRelayV1 = true)):
|
relay: Relay = Relay.new(circuitRelayV1 = true)):
|
||||||
Switch {.gcsafe, raises: [Defect, LPError].}
|
Switch {.gcsafe, raises: [LPError].}
|
||||||
DaemonPeerInfo = daemonapi.PeerInfo
|
DaemonPeerInfo = daemonapi.PeerInfo
|
||||||
|
|
||||||
proc writeLp(s: StreamTransport, msg: string | seq[byte]): Future[int] {.gcsafe.} =
|
proc writeLp(s: StreamTransport, msg: string | seq[byte]): Future[int] {.gcsafe.} =
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue