Skip to content

Commit

Permalink
Remove byteSize
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrsantos committed Sep 22, 2023
1 parent 42c9c70 commit ed568e9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
4 changes: 2 additions & 2 deletions libp2p/protocols/pubsub/gossipsub.nim
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,13 @@ proc rateLimit*(g: GossipSub, peer: PubSubPeer, rpcMsgOpt: Opt[RPCMsg], msgSize:

let usefulMsgBytesNum =
if g.verifySignature:
byteSize(rmsg.messages)
len(rmsg.messages)
else:
dataAndTopicsIdSize(rmsg.messages)

var uselessAppBytesNum = msgSize - usefulMsgBytesNum
rmsg.control.withValue(control):
uselessAppBytesNum -= (byteSize(control.ihave) + byteSize(control.iwant))
uselessAppBytesNum -= (len(control.ihave) + len(control.iwant))

peer.overheadRateLimitOpt.withValue(overheadRateLimit):
if not overheadRateLimit.tryConsume(uselessAppBytesNum):
Expand Down
18 changes: 0 additions & 18 deletions tests/pubsub/testgossipinternal.nim
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,6 @@ import ../helpers

proc noop(data: seq[byte]) {.async, gcsafe.} = discard

proc getPubSubPeer(p: TestGossipSub, peerId: PeerId): PubSubPeer =
proc getConn(): Future[Connection] =
p.switch.dial(peerId, GossipSubCodec)

let pubSubPeer = PubSubPeer.new(peerId, getConn, nil, GossipSubCodec, 1024 * 1024)
debug "created new pubsub peer", peerId

p.peers[peerId] = pubSubPeer

onNewPeer(p, pubSubPeer)
pubSubPeer

proc randomPeerId(): PeerId =
try:
PeerId.init(PrivateKey.random(ECDSA, rng[]).get()).tryGet()
except CatchableError as exc:
raise newException(Defect, exc.msg)

const MsgIdSuccess = "msg id gen success"

suite "GossipSub internal":
Expand Down

0 comments on commit ed568e9

Please sign in to comment.