mirror of
https://github.com/vacp2p/mix.git
synced 2026-01-09 21:07:59 -05:00
chore: rename shouldFwd to destIsExit (easier to read)
This commit is contained in:
@@ -52,7 +52,7 @@ method writeLp*(
|
||||
): Future[void] {.async: (raises: [CancelledError, LPStreamError], raw: true), public.} =
|
||||
var buf: seq[byte]
|
||||
|
||||
if shouldFwd(self.proto):
|
||||
if not destIsExit(self.proto):
|
||||
buf = @msg
|
||||
else:
|
||||
let length = msg.len().uint64
|
||||
|
||||
@@ -78,7 +78,7 @@ proc handleMixNodeConnection(
|
||||
receivedBytes,
|
||||
mixPrivKey,
|
||||
mixProto.tagManager,
|
||||
not ProtocolType.fromString(proto).shouldFwd,
|
||||
not ProtocolType.fromString(proto).destIsExit,
|
||||
)
|
||||
if processedPktRes.isErr:
|
||||
error "Failed to process Sphinx packet", err = processedPktRes.error
|
||||
@@ -108,7 +108,7 @@ proc handleMixNodeConnection(
|
||||
let (message, protocol) = getMixMessage(deserializedResult)
|
||||
trace "Exit node - Received mix message: ", receiver = multiAddr, message = message
|
||||
|
||||
if shouldFwd(protocol):
|
||||
if destIsExit(protocol):
|
||||
let exitConn = MixExitConnection.new(message)
|
||||
trace "Received: ", receiver = multiAddr, message = message
|
||||
await mixProto.pHandler(exitConn, protocol)
|
||||
@@ -287,7 +287,7 @@ proc anonymizeLocalProtocolSend*(
|
||||
|
||||
var i = 0
|
||||
while i < L:
|
||||
if shouldFwd(proto) and i == L - 1:
|
||||
if destIsExit(proto) and i == L - 1:
|
||||
randPeerId = destPeerId
|
||||
else:
|
||||
let randomIndexPosition = cryptoRandomInt(availableIndices.len).valueOr:
|
||||
@@ -299,7 +299,7 @@ proc anonymizeLocalProtocolSend*(
|
||||
availableIndices.del(randomIndexPosition)
|
||||
|
||||
# Skip the destination peer
|
||||
if not shouldFwd(proto) and randPeerId == destPeerId:
|
||||
if not destIsExit(proto) and randPeerId == destPeerId:
|
||||
continue
|
||||
|
||||
info "Selected mix node: ", indexInPath = i, peerId = randPeerId
|
||||
@@ -331,7 +331,7 @@ proc anonymizeLocalProtocolSend*(
|
||||
return
|
||||
|
||||
var destHop = none(Hop)
|
||||
if not shouldFwd(proto):
|
||||
if not destIsExit(proto):
|
||||
#Encode destination
|
||||
let dest = $destMultiAddr & "/p2p/" & $destPeerId
|
||||
let destAddrBytes = multiAddrToBytes(dest).valueOr:
|
||||
|
||||
@@ -26,8 +26,8 @@ proc fromString*(T: type ProtocolType, proto: string): ProtocolType =
|
||||
ProtocolType.OtherProtocol
|
||||
|
||||
# TODO: this is temporary while I attempt to extract protocol specific logic from mix
|
||||
func shouldFwd*(proto: ProtocolType): bool =
|
||||
return proto == GossipSub12 or proto == GossipSub11 or proto == GossipSub10
|
||||
func destIsExit*(proto: ProtocolType): bool =
|
||||
return not(proto == GossipSub12 or proto == GossipSub11 or proto == GossipSub10)
|
||||
|
||||
method callHandler*(
|
||||
switch: Switch, conn: Connection, proto: ProtocolType
|
||||
|
||||
Reference in New Issue
Block a user