Skip to content

Commit 340ea05

Browse files
feat: quic (#1265)
Co-authored-by: vladopajic <[email protected]>
1 parent 024ec51 commit 340ea05

File tree

21 files changed

+163
-71
lines changed

21 files changed

+163
-71
lines changed

.pinned

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ faststreams;https://github.com/status-im/nim-faststreams@#720fc5e5c8e428d9d0af61
66
httputils;https://github.com/status-im/nim-http-utils@#3b491a40c60aad9e8d3407443f46f62511e63b18
77
json_serialization;https://github.com/status-im/nim-json-serialization@#85b7ea093cb85ee4f433a617b97571bd709d30df
88
metrics;https://github.com/status-im/nim-metrics@#6142e433fc8ea9b73379770a788017ac528d46ff
9-
ngtcp2;https://github.com/status-im/nim-ngtcp2@#6834f4756b6af58356ac9c4fef3d71db3c3ae5fe
9+
ngtcp2;https://github.com/status-im/nim-ngtcp2@#9456daa178c655bccd4a3c78ad3b8cce1f0add73
1010
nimcrypto;https://github.com/cheatfate/nimcrypto@#1c8d6e3caf3abc572136ae9a1da81730c4eb4288
11-
quic;https://github.com/status-im/nim-quic.git@#ddcb31ffb74b5460ab37fd13547eca90594248bc
11+
quic;https://github.com/status-im/nim-quic.git@#51f20d2cbd79d02ec25ff29d87ee192d2b4cc2af
1212
results;https://github.com/arnetheduck/nim-results@#f3c666a272c69d70cb41e7245e7f6844797303ad
1313
secp256k1;https://github.com/status-im/nim-secp256k1@#7246d91c667f4cc3759fdd50339caa45a2ecd8be
1414
serialization;https://github.com/status-im/nim-serialization@#4bdbc29e54fe54049950e352bb969aab97173b35

libp2p.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ requires "nim >= 1.6.0",
1111
"nimcrypto >= 0.6.0 & < 0.7.0", "dnsclient >= 0.3.0 & < 0.4.0", "bearssl >= 0.2.5",
1212
"chronicles >= 0.10.2", "chronos >= 4.0.3", "metrics", "secp256k1", "stew#head",
1313
"websock", "unittest2",
14-
"https://github.com/status-im/nim-quic.git#ddcb31ffb74b5460ab37fd13547eca90594248bc"
14+
"https://github.com/status-im/nim-quic.git#51f20d2cbd79d02ec25ff29d87ee192d2b4cc2af"
1515

1616
let nimc = getEnv("NIMC", "nim") # Which nim compiler to use
1717
let lang = getEnv("NIMLANG", "c") # Which backend (c/cpp/js)

libp2p/builders.nim

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ import services/wildcardresolverservice
3838
export switch, peerid, peerinfo, connection, multiaddress, crypto, errors
3939

4040
type
41-
TransportProvider* {.public.} = proc(upgr: Upgrade): Transport {.gcsafe, raises: [].}
41+
TransportProvider* {.public.} =
42+
proc(upgr: Upgrade, privateKey: PrivateKey): Transport {.gcsafe, raises: [].}
4243

4344
SecureProtocol* {.pure.} = enum
4445
Noise
@@ -151,7 +152,7 @@ proc withTransport*(
151152
let switch = SwitchBuilder
152153
.new()
153154
.withTransport(
154-
proc(upgr: Upgrade): Transport =
155+
proc(upgr: Upgrade, privateKey: PrivateKey): Transport =
155156
TcpTransport.new(flags, upgr)
156157
)
157158
.build()
@@ -162,7 +163,7 @@ proc withTcpTransport*(
162163
b: SwitchBuilder, flags: set[ServerFlags] = {}
163164
): SwitchBuilder {.public.} =
164165
b.withTransport(
165-
proc(upgr: Upgrade): Transport =
166+
proc(upgr: Upgrade, privateKey: PrivateKey): Transport =
166167
TcpTransport.new(flags, upgr)
167168
)
168169

@@ -270,7 +271,7 @@ proc build*(b: SwitchBuilder): Switch {.raises: [LPError], public.} =
270271
let transports = block:
271272
var transports: seq[Transport]
272273
for tProvider in b.transports:
273-
transports.add(tProvider(muxedUpgrade))
274+
transports.add(tProvider(muxedUpgrade, seckey))
274275
transports
275276

276277
if b.secureManagers.len == 0:

libp2p/dial.nim

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ method connect*(
3131
## a protocol
3232
##
3333

34-
doAssert(false, "Not implemented!")
34+
doAssert(false, "[Dial.connect] abstract method not implemented!")
3535

3636
method connect*(
3737
self: Dial, address: MultiAddress, allowUnknownPeerId = false
3838
): Future[PeerId] {.base, async: (raises: [DialFailedError, CancelledError]).} =
3939
## Connects to a peer and retrieve its PeerId
4040

41-
doAssert(false, "Not implemented!")
41+
doAssert(false, "[Dial.connect] abstract method not implemented!")
4242

4343
method dial*(
4444
self: Dial, peerId: PeerId, protos: seq[string]
@@ -47,7 +47,7 @@ method dial*(
4747
## existing connection
4848
##
4949

50-
doAssert(false, "Not implemented!")
50+
doAssert(false, "[Dial.dial] abstract method not implemented!")
5151

5252
method dial*(
5353
self: Dial,
@@ -60,14 +60,14 @@ method dial*(
6060
## a connection if one doesn't exist already
6161
##
6262

63-
doAssert(false, "Not implemented!")
63+
doAssert(false, "[Dial.dial] abstract method not implemented!")
6464

6565
method addTransport*(self: Dial, transport: Transport) {.base.} =
66-
doAssert(false, "Not implemented!")
66+
doAssert(false, "[Dial.addTransport] abstract method not implemented!")
6767

6868
method tryDial*(
6969
self: Dial, peerId: PeerId, addrs: seq[MultiAddress]
7070
): Future[Opt[MultiAddress]] {.
7171
base, async: (raises: [DialFailedError, CancelledError])
7272
.} =
73-
doAssert(false, "Not implemented!")
73+
doAssert(false, "[Dial.tryDial] abstract method not implemented!")

libp2p/discovery/discoverymngr.nim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ proc `{}`*[T](pa: PeerAttributes, t: typedesc[T]): Opt[T] =
5959

6060
proc `[]`*[T](pa: PeerAttributes, t: typedesc[T]): T {.raises: [KeyError].} =
6161
pa{T}.valueOr:
62-
raise newException(KeyError, "Attritute not found")
62+
raise newException(KeyError, "Attribute not found")
6363

6464
proc match*(pa, candidate: PeerAttributes): bool =
6565
for f in pa.attributes:
@@ -86,12 +86,12 @@ type
8686
method request*(
8787
self: DiscoveryInterface, pa: PeerAttributes
8888
) {.base, async: (raises: [DiscoveryError, CancelledError]).} =
89-
doAssert(false, "Not implemented!")
89+
doAssert(false, "[DiscoveryInterface.request] abstract method not implemented!")
9090

9191
method advertise*(
9292
self: DiscoveryInterface
9393
) {.base, async: (raises: [CancelledError, AdvertiseError]).} =
94-
doAssert(false, "Not implemented!")
94+
doAssert(false, "[DiscoveryInterface.advertise] abstract method not implemented!")
9595

9696
type
9797
DiscoveryQuery* = ref object

libp2p/muxers/muxer.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ method newStream*(
5252
): Future[Connection] {.
5353
base, async: (raises: [CancelledError, LPStreamError, MuxerError], raw: true)
5454
.} =
55-
raiseAssert("Not implemented!")
55+
raiseAssert("[Muxer.newStream] abstract method not implemented!")
5656

5757
method close*(m: Muxer) {.base, async: (raises: []).} =
5858
if m.connection != nil:
@@ -68,4 +68,4 @@ proc new*(
6868
muxerProvider
6969

7070
method getStreams*(m: Muxer): seq[Connection] {.base, gcsafe.} =
71-
raiseAssert("Not implemented!")
71+
raiseAssert("[Muxer.getStreams] abstract method not implemented!")

libp2p/nameresolving/nameresolver.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ method resolveTxt*(
2222
self: NameResolver, address: string
2323
): Future[seq[string]] {.async: (raises: [CancelledError]), base.} =
2424
## Get TXT record
25-
raiseAssert "Not implemented!"
25+
raiseAssert "[NameResolver.resolveTxt] abstract method not implemented!"
2626

2727
method resolveIp*(
2828
self: NameResolver, address: string, port: Port, domain: Domain = Domain.AF_UNSPEC
2929
): Future[seq[TransportAddress]] {.
3030
async: (raises: [CancelledError, TransportAddressError]), base
3131
.} =
3232
## Resolve the specified address
33-
raiseAssert "Not implemented!"
33+
raiseAssert "[NameResolver.resolveIp] abstract method not implemented!"
3434

3535
proc getHostname*(ma: MultiAddress): string =
3636
let

libp2p/protocols/secure/secure.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ method readMessage*(
8282
): Future[seq[byte]] {.
8383
async: (raises: [CancelledError, LPStreamError], raw: true), base
8484
.} =
85-
raiseAssert("Not implemented!")
85+
raiseAssert("[SecureConn.readMessage] abstract method not implemented!")
8686

8787
method getWrapped*(s: SecureConn): Connection =
8888
s.stream
@@ -92,7 +92,7 @@ method handshake*(
9292
): Future[SecureConn] {.
9393
async: (raises: [CancelledError, LPStreamError], raw: true), base
9494
.} =
95-
raiseAssert("Not implemented!")
95+
raiseAssert("[Secure.handshake] abstract method not implemented!")
9696

9797
proc handleConn(
9898
s: Secure, conn: Connection, initiator: bool, peerId: Opt[PeerId]

libp2p/stream/connection.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ proc timeoutMonitor(s: Connection) {.async: (raises: []).} =
124124
return
125125

126126
method getWrapped*(s: Connection): Connection {.base.} =
127-
raiseAssert("Not implemented!")
127+
raiseAssert("[Connection.getWrapped] abstract method not implemented!")
128128

129129
when defined(libp2p_agents_metrics):
130130
proc setShortAgent*(s: Connection, shortAgent: string) =

libp2p/stream/lpstream.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ method readOnce*(
133133
## Reads whatever is available in the stream,
134134
## up to `nbytes`. Will block if nothing is
135135
## available
136-
raiseAssert("Not implemented!")
136+
raiseAssert("[LPStream.readOnce] abstract method not implemented!")
137137

138138
proc readExactly*(
139139
s: LPStream, pbytes: pointer, nbytes: int
@@ -242,7 +242,7 @@ method write*(
242242
async: (raises: [CancelledError, LPStreamError], raw: true), base, public
243243
.} =
244244
# Write `msg` to stream, waiting for the write to be finished
245-
raiseAssert("Not implemented!")
245+
raiseAssert("[LPStream.write] abstract method not implemented!")
246246

247247
proc writeLp*(
248248
s: LPStream, msg: openArray[byte]

0 commit comments

Comments
 (0)