Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions libp2p_mix.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ description =
license = "MIT"
skipDirs = @["examples", "tests"]

# nim-libp2p pinned to a master commit that includes `pick` utilities (PR #2245).
# Bump as needed; downstream consumers should align their libp2p pin to match.
# nim-libp2p pinned to the tip of the mix-deletion PR branch
# (vacp2p/nim-libp2p#2378). That commit has `MixPubKeyBook` removed from
# libp2p/peerstore — required so the local definition in libp2p_mix/pool
# is unambiguous. Once #2378 merges to master and is published, replace
# the pin with `libp2p >= <new-version>`.
requires "nim >= 2.0.0",
"https://github.com/vacp2p/nim-libp2p.git#bd2d5a745de2844dc326e421b0cb1662541e0d6e",
"https://github.com/vacp2p/nim-libp2p.git#074fe1560bc8a413315e2f3d917a63f0ac12105f",
"chronicles >= 0.11.0", "chronos >= 4.2.2", "metrics", "nimcrypto >= 0.6.0",
"bearssl >= 0.2.7", "stew >= 0.4.2", "results", "unittest2"

Expand Down
4 changes: 2 additions & 2 deletions libp2p_mix/entry_connection.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ chronicles.formatIt(MixEntryConnection):

method readOnce*(
s: MixEntryConnection, pbytes: pointer, nbytes: int
): Future[int] {.async: (raises: [CancelledError, LPStreamError]), public.} =
): Future[int] {.async: (raises: [CancelledError, LPStreamError]).} =
if s.isEof:
raise newLPStreamEOFError()

Expand Down Expand Up @@ -69,7 +69,7 @@ method readOnce*(

method write*(
self: MixEntryConnection, msg: seq[byte]
): Future[void] {.async: (raises: [CancelledError, LPStreamError]), public.} =
): Future[void] {.async: (raises: [CancelledError, LPStreamError]).} =
if msg.len() > DataSize:
raise newException(LPStreamError, "exceeds max msg size of " & $DataSize & " bytes")
await self.mixDialer(msg, self.codec, self.destination)
Expand Down
4 changes: 2 additions & 2 deletions libp2p_mix/exit_connection.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type MixExitConnection* = ref object of Connection

method readOnce*(
self: MixExitConnection, pbytes: pointer, nbytes: int
): Future[int] {.async: (raises: [CancelledError, LPStreamError]), public.} =
): Future[int] {.async: (raises: [CancelledError, LPStreamError]).} =
if self.message.len == 0:
return 0 # Nothing else to read.
if self.message.len < nbytes:
Expand All @@ -24,7 +24,7 @@ method readOnce*(

method write*(
self: MixExitConnection, msg: seq[byte]
): Future[void] {.async: (raises: [CancelledError, LPStreamError]), public.} =
): Future[void] {.async: (raises: [CancelledError, LPStreamError]).} =
if msg.len() > DataSize:
raise newException(LPStreamError, "exceeds max msg size of " & $DataSize & " bytes")
self.response.add(msg)
Expand Down
5 changes: 5 additions & 0 deletions libp2p_mix/pool.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ import ./multiaddr as mix_multiaddr

export mix_node.MixPubInfo

type MixPubKeyBook* = ref object of PeerBook[Curve25519Key]
## Tracks Curve25519 mix public keys per peer. Defined here so the mix
## package owns its peer-store extension and libp2p core stays free of
## mix-specific types.

func isSupportedMultiaddr(maddr: MultiAddress): bool =
## Returns true if the multiaddress is supported by the mix protocol.
## Mix protocol supports IPv4 addresses with TCP or QUIC-v1 transports,
Expand Down
4 changes: 2 additions & 2 deletions libp2p_mix/reply_connection.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ type MixReplyConnection* = ref object of Connection

method readExactly*(
self: MixReplyConnection, pbytes: pointer, nbytes: int
): Future[void] {.async: (raises: [CancelledError, LPStreamError]), public.} =
): Future[void] {.async: (raises: [CancelledError, LPStreamError]).} =
raise newException(LPStreamError, "MixReplyConnection does not allow reading")

method write*(
self: MixReplyConnection, msg: seq[byte]
): Future[void] {.async: (raises: [CancelledError, LPStreamError]), public.} =
): Future[void] {.async: (raises: [CancelledError, LPStreamError]).} =
if msg.len() > DataSize:
raise newException(LPStreamError, "exceeds max msg size of " & $DataSize & " bytes")
await self.mixReplyDialer(self.surbs, msg)
Expand Down
Loading