Compare commits

...

1 Commits

Author SHA1 Message Date
Richard Ramos
f39c1e037c feat: add skipIDontWant and skipPreamble 2025-09-10 10:39:19 -04:00
2 changed files with 18 additions and 2 deletions

View File

@@ -932,11 +932,12 @@ method publish*(
g.mcache.put(msgId, msg)
if g.parameters.sendIDontWantOnPublish:
if isLargeMessage(msg, msgId):
if not pubParams.skipIDontWant and isLargeMessage(msg, msgId):
g.sendIDontWant(msg, msgId, peers)
when defined(libp2p_gossipsub_1_4):
g.sendPreamble(msg, msgId, peers)
if not pubParams.skipPreamble:
g.sendPreamble(msg, msgId, peers)
g.broadcast(
peers,

View File

@@ -146,9 +146,24 @@ type
## This callback can be used to reject topic we're not interested in
PublishParams* = object
## Used to indicate whether a message will be broadcasted using a custom connection
## defined when instantiating Pubsub, or if it will use the normal connection
useCustomConn*: bool
## Can be used to avoid having the node reply to IWANT messages when initially
## broadcasting a message, it's only after relaying its own message that the
## node will reply to IWANTs
skipMCache*: bool
## Determines whether an IDontWant message will be sent for the current message
## when it is published if it's a large message.
skipIDontWant*: bool
when defined(libp2p_gossipsub_1_4):
## Determines whether a Preamble message will be sent for the current message
## when it is published if it's a large message
skipPreamble*: bool
PubSub* {.public.} = ref object of LPProtocol
switch*: Switch # the switch used to dial/connect to peers
peerInfo*: PeerInfo # this peer's info