libp2p/protocols/pubsub/pubsubpeer

    Dark Mode
Search:
Group by:
  Source   Edit

Types

DropConn = proc (peer: PubSubPeer) {....gcsafe, raises: [].}
  Source   Edit
GetConn = proc (): Future[Connection] {....gcsafe, raises: [].}
  Source   Edit
OnEvent = proc (peer: PubSubPeer; event: PubSubPeerEvent) {....gcsafe, raises: [].}
  Source   Edit
PeerRateLimitError = object of CatchableError
  Source   Edit
PubSubObserver = ref object
  onRecv*: proc (peer: PubSubPeer; msgs: var RPCMsg) {....gcsafe, raises: [].}
  onSend*: proc (peer: PubSubPeer; msgs: var RPCMsg) {....gcsafe, raises: [].}
  Source   Edit
PubSubPeer = ref object of RootObj
  getConn*: GetConn
  onEvent*: OnEvent
  codec*: string
  sendConn*: Connection
  connectedFut: Future[void]
  address*: Option[MultiAddress]
  peerId*: PeerId
  handler*: RPCHandler
  observers*: ref seq[PubSubObserver]
  score*: float64
  sentIHaves*: Deque[HashSet[MessageId]]
  heDontWants*: Deque[HashSet[SaltedId]] ## IDONTWANT contains unvalidated message id:s which may be long and/or
                                         ## expensive to look up, so we apply the same salting to them as during
                                         ## unvalidated message processing
  iHaveBudget*: int
  pingBudget*: int
  maxMessageSize: int
  appScore*: float64
  behaviourPenalty*: float64
  overheadRateLimitOpt*: Opt[TokenBucket]
  rpcmessagequeue: RpcMessageQueue
  maxNumElementsInNonPriorityQueue*: int
  Source   Edit
PubSubPeerEventKind {.pure.} = enum
  StreamOpened, StreamClosed, DisconnectionRequested
  Source   Edit
RPCHandler = proc (peer: PubSubPeer; data: seq[byte]): Future[void] {....gcsafe,
    raises: [].}
  Source   Edit
RpcMessageQueue = ref object
  sendPriorityQueue: Deque[Future[void]]
  nonPriorityQueue: AsyncQueue[seq[byte]]
  sendNonPriorityTask: Future[void]
  Source   Edit

Procs

func `==`(a, b: PubSubPeer): bool {....raises: [], tags: [].}
  Source   Edit
proc canAskIWant(p: PubSubPeer; msgId: MessageId): bool {....raises: [], tags: [].}
  Source   Edit
proc clearNonPriorityQueue(p: PubSubPeer) {....raises: [], tags: [].}
  Source   Edit
proc connect(p: PubSubPeer) {....raises: [], tags: [RootEffect].}
  Source   Edit
proc connected(p: PubSubPeer): bool {....raises: [], tags: [].}
  Source   Edit
proc getAgent(peer: PubSubPeer): string {....raises: [], tags: [].}
  Source   Edit
proc handle(p: PubSubPeer; conn: Connection): Future[void] {.stackTrace: false,
    ...raises: [], gcsafe, raises: [], raises: [], tags: [RootEffect].}
  Source   Edit
func hash(p: PubSubPeer): Hash {....raises: [], tags: [].}
  Source   Edit
proc hasObservers(p: PubSubPeer): bool {....raises: [], tags: [].}
  Source   Edit
proc hasSendConn(p: PubSubPeer): bool {....raises: [], tags: [].}
  Source   Edit
proc new(T: typedesc[PubSubPeer]; peerId: PeerId; getConn: GetConn;
         onEvent: OnEvent; codec: string; maxMessageSize: int;
    maxNumElementsInNonPriorityQueue: int = DefaultMaxNumElementsInNonPriorityQueue;
         overheadRateLimitOpt: Opt[TokenBucket] = Opt.none(TokenBucket)): T:type {.
    ...raises: [].}
  Source   Edit
func outbound(p: PubSubPeer): bool {....raises: [], tags: [].}
  Source   Edit
proc recvObservers(p: PubSubPeer; msg: var RPCMsg) {....raises: [],
    tags: [RootEffect].}
  Source   Edit
proc send(p: PubSubPeer; msg: RPCMsg; anonymize: bool; isHighPriority: bool) {.
    ...raises: [], raises: [], tags: [RootEffect, WriteIOEffect, TimeEffect].}

Asynchronously sends an RPCMsg to a specified PubSubPeer with an option for anonymization.

Parameters:

  • p: The PubSubPeer instance to which the message is to be sent.
  • msg: The RPCMsg instance representing the message to be sent.
  • anonymize: A boolean flag indicating whether the message should be sent with anonymization.
  • isHighPriority: A boolean flag indicating whether the message should be treated as high priority.

High priority messages are sent immediately, while low priority messages are queued and sent only after all high priority messages have been sent.

  Source   Edit
proc sendEncoded(p: PubSubPeer; msg: seq[byte]; isHighPriority: bool): Future[
    void] {....raises: [], tags: [WriteIOEffect, TimeEffect, RootEffect].}

Asynchronously sends an encoded message to a specified PubSubPeer.

Parameters:

  • p: The PubSubPeer instance to which the message is to be sent.
  • msg: The message to be sent, encoded as a sequence of bytes (seq[byte]).
  • isHighPriority: A boolean indicating whether the message should be treated as high priority.

High priority messages are sent immediately, while low priority messages are queued and sent only after all high priority messages have been sent.

  Source   Edit
func shortLog(p: PubSubPeer): string {....raises: [], tags: [].}
  Source   Edit
proc stopSendNonPriorityTask(p: PubSubPeer) {....raises: [],
    tags: [WriteIOEffect, TimeEffect, RootEffect].}
  Source   Edit

Templates

template formatItIMPL(it: PubSubPeer): auto
  Source   Edit

Exports

formatItIMPL, hash, shortLog, random, $, write, PeerId, ==, getField, <=, capLen, init, validate, init, match, <, getBytes, maxInlineKeyLength, write, withValue, safeConvert, shortLog, >=, withValue, public, shortLog, compilesOr, toBytes, match, valueOr, init, init, init, toOpt, init, hasPublicKey, >, hex, len, exceptionToAssert, cmp, extractPublicKey, DNS_OR_IP, shortLog, random, UDP_DNS, $, getProtoHeader, MaError, ephemeral, MaPatternOp, ==, WS_DNS, initVBuffer, getProtoHeader, MaxSizeError, ProtoHeader, ProtoFlags, getLen, ECDHEScheme, shortLog, init, closed, [], macOpenArray, random, init, VBuffer, Secret, peekVarint, random, $, validate, bytes, maxInlineKeyLength, TranscoderDNS, QUIC, [], init, ephemeral, withValue, getRequiredField, getField, supported, WS_IP, write, public, MAKind, write, checkFieldNumber, valueOr, getRepeatedField, matchPartial, libp2p_pki_schemes, getBytes, len, readVarint, readLp, HTTP, initVBuffer, atEof, LPStreamTrackerName, write, toOpt, fullAddrs, payloadType, <=, LPStreamError, init, IP, protoAddress, newRng, DefaultConnectionTimeout, ==, checkValid, mac, getPublicKey, exceptionToAssert, len, CircuitRelay, extractPublicKey, mapAnd, new, verify, UDP_IP, new, newLPStreamEOFError, init, ==, DNSADDR, AddressMapper, init, write, PeerId, WSS, LPStream, TCP_IP, close, writePacked, init, init, closeImpl, readSeq, toBytes, TCP_DNS, shortLog, encode, len, capLen, init, protoName, toRawBytes, mapOr, $, initProtoBuffer, init, WSS_DNS, match, writeLPVarint, CryptoResult, parseFullAddress, ProtoResult, WebRTCDirect, init, init, UDP, TranscoderOnion, StreamTracker, write, init, LPStreamResetError, isEmpty, writeArray, decode, LPStreamIncompleteError, [], LPStreamEOFError, IP6, shortLog, initVBuffer, decode, PKScheme, toString, payload, init, stretchKeys, Connection, write, DNSANY, TCP, PrivateKey, getBytes, write, init, &=, PeerInfoError, hash, newLPStreamClosedError, random, write, compilesOr, TranscoderIP4, init, initProtoBuffer, toException, DNS, UTP, goffset, getRawBytes, >, KeyPair, init, init, high, cmp, init, SupportedWireTypes, formatItIMPL, formatItIMPL, formatItIMPL, Signature, contains, formatItIMPL, toBytes, DigestSheme, IPFS, getField, readOnce, isEmpty, ProtoScalar, shortLog, data, hex, protocols, HTTPS, WebSockets, LPError, getPtr, write, TLS_WS, sign, init, encode, update, MaResult, init, ProtoField, toBytes, writeSeq, init, &, DNS6, IpTransportProtocol, toOpenArray, init, IP4, TranscoderPort, isEnough, safeConvert, getField, init, >=, readVarint, payloadDomain, $, MaPattern, withValue, LPStreamLimitError, TranscoderOnion3, SignedPayload, toBytes, protoArgument, newLPStreamLimitError, write, keyOpenArray, match, parseFullAddress, $, isEmpty, writeLp, getRequiredRepeatedField, init, newLPStreamIncompleteError, initProtoBuffer, MAProtocol, newLPStreamResetError, getPackedRepeatedField, initStream, init, getField, shortLog, DNS4, getWrapped, readArray, selectBest, write, P2PPattern, Envelope, hasPublicKey, toException, isEnough, init, Reliable, addrs, hex, ProtoBuffer, closeImpl, getBytes, WS, init, init, encode, init, finish, getField, match, <, iv, readLine, Eof, CryptoError, getField, hash, append, vsizeof, init, WebSockets_DNS, WSS_IP, LPStreamConnDownError, peekArray, UNIX, PeerRecord, SupportedSchemes, getRepeatedField, getField, Unreliable, SupportedSchemesInt, random, checkFutures, shuffle, key, validate, $, protoCode, mapEq, getField, Onion3, write, TcpOnion3, concat, TranscoderP2P, PeerInfo, AddressInfo, ConnectionTrackerName, TranscoderIP6, finish, write, EnvelopeError, hash, encode, newLPStreamRemoteClosedError, TranscoderIP6Zone, MaPatResult, Direction, init, InvalidVarintError, decode, shortLog, items, ==, init, peekSeq, getBytes, write, init, init, init, PublicKey, WebSockets_IP, writeLp, writePBVarint, ProtoFieldKind, readExactly, protoArgument, getRepeatedField, ProtoError, newLPStreamConnDownError, initStream, getField, MultiAddress, ivOpenArray, closeWithEOF, TimeoutHandler, orError, getField, LPStreamRemoteClosedError, MaInvalidAddress, LPStreamClosedError, RsaDefaultKeySize, write, getOrder, TranscoderUnix, SignedPeerRecord, join, writeVarint