Skip to content

Commit

Permalink
Remove send test
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrsantos committed Sep 7, 2023
1 parent fda424a commit 5441441
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 75 deletions.
2 changes: 1 addition & 1 deletion libp2p/protocols/pubsub/pubsub.nim
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ proc send*(p: PubSub, peer: PubSubPeer, msg: RPCMsg) {.raises: [].} =
##

trace "sending pubsub message to peer", peer, msg = shortLog(msg)
discard peer.send(msg, p.anonymize)
peer.send(msg, p.anonymize)

proc broadcast*(
p: PubSub,
Expand Down
7 changes: 1 addition & 6 deletions libp2p/protocols/pubsub/pubsubpeer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ proc sendEncoded*(p: PubSubPeer, msg: seq[byte]) {.raises: [], async.} =

await conn.close() # This will clean up the send connection

proc send*(p: PubSubPeer, msg: RPCMsg, anonymize: bool): seq[RPCMsg] {.raises: [].} =
proc send*(p: PubSubPeer, msg: RPCMsg, anonymize: bool) {.raises: [].} =
# When sending messages, we take care to re-encode them with the right
# anonymization flag to ensure that we're not penalized for sending invalid
# or malicious data on the wire - in particular, re-encoding protects against
Expand All @@ -290,8 +290,6 @@ proc send*(p: PubSubPeer, msg: RPCMsg, anonymize: bool): seq[RPCMsg] {.raises: [
sendMetrics(msg)
encodeRpcMsg(msg, anonymize)

var sentMessages: seq[RPCMsg]
# Check if the encoded message size exceeds the maxMessageSize
if encoded.len > p.maxMessageSize:
var controlSent = false
# Split the RPCMsg into individual messages and send them separately
Expand All @@ -305,13 +303,10 @@ proc send*(p: PubSubPeer, msg: RPCMsg, anonymize: bool): seq[RPCMsg] {.raises: [
let newMsgEncoded = encodeRpcMsg(newMsg, anonymize)
trace "sending msg to peer", peer = p, rpcMsg = shortLog(newMsg)
asyncSpawn p.sendEncoded(newMsgEncoded)
sentMessages.add(newMsg)
else:
# If the message size is within limits, send it as is
trace "sending msg to peer", peer = p, rpcMsg = shortLog(msg)
asyncSpawn p.sendEncoded(encoded)
sentMessages.add(msg)
return sentMessages

proc canAskIWant*(p: PubSubPeer, msgId: MessageId): bool =
for sentIHave in p.sentIHaves.mitems():
Expand Down
68 changes: 0 additions & 68 deletions tests/pubsub/testpubsubpeer.nim

This file was deleted.

0 comments on commit 5441441

Please sign in to comment.