# compile time options here const libp2p_pubsub_sign {.booldefine.} = true libp2p_pubsub_verify {.booldefine.} = true libp2p_pubsub_anonymize {.booldefine.} = false import hashes, random, tables import chronos, stew/[byteutils, results] import ../../libp2p/[builders, protocols/pubsub/errors, protocols/pubsub/pubsub, protocols/pubsub/gossipsub, protocols/pubsub/floodsub, protocols/pubsub/rpc/messages, protocols/secure/secure] export builders randomize() func defaultMsgIdProvider*(m: Message): Result[MessageID, ValidationResult] = let mid = if m.seqno.len > 0 and m.fromPeer.data.len > 0: byteutils.toHex(m.seqno) & $m.fromPeer else: # This part is irrelevant because it's not standard, # We use it exclusively for testing basically and users should # implement their own logic in the case they use anonymization $m.data.hash & $m.topicIDs.hash ok mid.toBytes() proc generateNodes*( num: Natural, secureManagers: openArray[SecureProtocol] = [ SecureProtocol.Noise ], msgIdProvider: MsgIdProvider = defaultMsgIdProvider, gossip: bool = false, triggerSelf: bool = false, verifySignature: bool = libp2p_pubsub_verify, anonymize: bool = libp2p_pubsub_anonymize, sign: bool = libp2p_pubsub_sign, unsubscribeBackoff = 1.seconds, maxMessageSize: int = 1024 * 1024): seq[PubSub] = for i in 0..