mirror of
https://github.com/vacp2p/nim-libp2p.git
synced 2026-01-10 12:58:05 -05:00
Compare commits
6 Commits
quic-large
...
pwhite/mix
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9282d3a2f | ||
|
|
6c70603d7a | ||
|
|
7072e3e385 | ||
|
|
05367a08fe | ||
|
|
a83d648d2c | ||
|
|
74e216a095 |
@@ -9,7 +9,7 @@ skipDirs = @["tests", "examples", "Nim", "tools", "scripts", "docs"]
|
||||
|
||||
requires "nim >= 2.0.0",
|
||||
"nimcrypto >= 0.6.0 & < 0.7.0", "dnsclient >= 0.3.0 & < 0.4.0", "bearssl >= 0.2.5",
|
||||
"chronicles >= 0.11.0 & < 0.12.0", "chronos >= 4.0.4", "metrics", "secp256k1",
|
||||
"chronicles >= 0.11.0", "chronos >= 4.0.4", "metrics", "secp256k1",
|
||||
"stew >= 0.4.0", "websock >= 0.2.0", "unittest2", "results", "quic >= 0.2.10",
|
||||
"https://github.com/vacp2p/nim-jwt.git#18f8378de52b241f321c1f9ea905456e89b95c6f"
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
{.push raises: [].}
|
||||
|
||||
import std/[sets, sequtils]
|
||||
import stew/[endians2]
|
||||
import chronos, chronicles, metrics
|
||||
import chronos/ratelimit
|
||||
import
|
||||
@@ -648,6 +649,8 @@ method rpcHandler*(
|
||||
for m in rpcMsg.messages:
|
||||
libp2p_pubsub_received_messages.inc(labelValues = [$peer.peerId, m.topic])
|
||||
|
||||
let fromPeerID = peer
|
||||
|
||||
trace "decoded msg from peer", peer, payload = rpcMsg.shortLog
|
||||
await rateLimit(g, peer, g.messageOverhead(rpcMsg, msgSize))
|
||||
|
||||
@@ -716,6 +719,12 @@ method rpcHandler*(
|
||||
# onto the next message
|
||||
continue
|
||||
|
||||
if msg.data.len == 100:
|
||||
info "Received message from handler",
|
||||
msgid = uint64.fromBytesLE(msg.data[8 ..< 16]),
|
||||
fromPeerID = fromPeerID,
|
||||
orig = uint64.fromBytesLE(msg.data[0 ..< 8])
|
||||
|
||||
libp2p_gossipsub_received.inc()
|
||||
|
||||
# avoid processing messages we are not interested in
|
||||
|
||||
@@ -770,7 +770,7 @@ proc getGossipPeers*(g: GossipSub): Table[PubSubPeer, ControlMessage] =
|
||||
|
||||
cacheWindowSize += midsSeq.len
|
||||
|
||||
trace "got messages to emit", size = midsSeq.len
|
||||
info "got messages to emit", size = midsSeq.len
|
||||
|
||||
# not in spec
|
||||
# similar to rust: https://github.com/sigp/rust-libp2p/blob/f53d02bc873fef2bf52cd31e3d5ce366a41d8a8c/protocols/gossipsub/src/behaviour.rs#L2101
|
||||
|
||||
@@ -275,6 +275,9 @@ proc broadcast*(
|
||||
else:
|
||||
# Fast path that only encodes message once
|
||||
let encoded = encodeRpcMsg(msg, p.anonymize)
|
||||
|
||||
info "SEND ENCODED MSG 1", data = shortLog(msg), useCustomConn, isHighPriority
|
||||
|
||||
for peer in sendPeers:
|
||||
asyncSpawn peer.sendEncoded(encoded, isHighPriority, useCustomConn)
|
||||
|
||||
|
||||
@@ -382,7 +382,8 @@ proc sendMsgSlow(p: PubSubPeer, msg: seq[byte]) {.async: (raises: [CancelledErro
|
||||
debug "No send connection", p, payload = shortLog(msg)
|
||||
return
|
||||
|
||||
trace "sending encoded msg to peer", conn, encoded = shortLog(msg)
|
||||
info "sending encoded msg to peer", conn, encoded = shortLog(msg)
|
||||
writeStackTrace()
|
||||
await sendMsgContinue(conn, conn.writeLp(msg))
|
||||
|
||||
proc sendMsg(
|
||||
@@ -408,7 +409,7 @@ proc sendMsg(
|
||||
(nil, ctSlow)
|
||||
|
||||
if not slowPath:
|
||||
trace "sending encoded msg to peer",
|
||||
info "sending encoded msg to peer",
|
||||
conntype = $connType, conn = conn, encoded = shortLog(msg)
|
||||
let f = conn.writeLp(msg)
|
||||
if not f.completed():
|
||||
@@ -545,9 +546,11 @@ proc send*(
|
||||
if encoded.len > p.maxMessageSize and msg.messages.len > 1:
|
||||
for encodedSplitMsg in splitRPCMsg(p, msg, p.maxMessageSize, anonymize):
|
||||
asyncSpawn p.sendEncoded(encodedSplitMsg, isHighPriority, useCustomConn)
|
||||
info "SEND ENCODED MSG 2", data = shortLog(msg), useCustomConn, isHighPriority
|
||||
else:
|
||||
# If the message size is within limits, send it as is
|
||||
trace "sending msg to peer", peer = p, rpcMsg = shortLog(msg)
|
||||
info "SEND ENCODED MSG 3", data = shortLog(msg), useCustomConn, isHighPriority
|
||||
asyncSpawn p.sendEncoded(encoded, isHighPriority, useCustomConn)
|
||||
|
||||
proc canAskIWant*(p: PubSubPeer, msgId: MessageId): bool =
|
||||
|
||||
Reference in New Issue
Block a user