libp2p/protocols/pubsub/pubsubpeer

Search:
Group by:
Source   Edit  

Types

CustomConnCreationProc = proc (destAddr: Option[MultiAddress];
                               destPeerId: PeerId; codec: string): Connection {.
    ...gcsafe, raises: [].}
Source   Edit  
CustomConnectionCallbacks = object
  customConnCreationCB*: CustomConnCreationProc
  customPeerSelectionCB*: CustomPeerSelectionProc
Source   Edit  
CustomPeerSelectionProc = proc (allPeers: HashSet[PubSubPeer];
                                directPeers: HashSet[PubSubPeer];
                                meshPeers: HashSet[PubSubPeer];
                                fanoutPeers: HashSet[PubSubPeer]): HashSet[
    PubSubPeer] {....gcsafe, raises: [].}
Source   Edit  
DropConn = proc (peer: PubSubPeer) {....gcsafe, raises: [].}
Source   Edit  
GetConn = proc (): Future[Connection] {.async: (
    ...raises: [CancelledError, GetConnDialError]).}
Source   Edit  
GetConnDialError = object of CatchableError
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: [].}
  onValidated*: proc (peer: PubSubPeer; msg: Message; msgId: MessageId) {.
      ...gcsafe, raises: [].}
Source   Edit  
PubSubPeer = ref object of RootObj
  getConn*: GetConn
  onEvent*: OnEvent
  codec*: string
  sendConn*: Connection
  address*: Option[MultiAddress]
  peerId*: PeerId
  handler*: RPCHandler
  observers*: ref seq[PubSubObserver]
  when defined(libp2p_gossipsub_1_4):
    bandwidthTracking*: BandwidthTracking
  score*: float64
  sentIHaves*: Deque[HashSet[MessageId]]
  iDontWants*: 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
  appScore*: float64
  behaviourPenalty*: float64
  overheadRateLimitOpt*: Opt[TokenBucket]
  when defined(libp2p_gossipsub_1_4):
    preambleBudget*: int
    heIsReceivings*: Table[MessageId, uint32]
    heIsSendings*: Table[MessageId, Moment]
  maxNumElementsInNonPriorityQueue*: int
  customConnCallbacks*: Option[CustomConnectionCallbacks]
Source   Edit  
PubSubPeerEventKind {.pure.} = enum
  StreamOpened, StreamClosed, DisconnectionRequested
Source   Edit  
RPCHandler = proc (peer: PubSubPeer; data: sink seq[byte]): Future[void] {.
    async: (...raises: [CancelledError]).}
Source   Edit  
RpcMessageQueue = ref object
Source   Edit  

Procs

proc `$`(p: PubSubPeer): string {....raises: [], tags: [], forbids: [].}
Source   Edit  
func `==`(a, b: PubSubPeer): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc canAskIWant(p: PubSubPeer; msgId: MessageId): bool {....raises: [], tags: [],
    forbids: [].}
Source   Edit  
proc connect(p: PubSubPeer) {....raises: [], tags: [RootEffect], forbids: [].}
Source   Edit  
proc connected(p: PubSubPeer): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc getAgent(peer: PubSubPeer): string {....raises: [], tags: [], forbids: [].}
Source   Edit  
func hash(p: PubSubPeer): Hash {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc hasObservers(p: PubSubPeer): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc hasSendConn(p: PubSubPeer): bool {....raises: [], tags: [], forbids: [].}
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);
    customConnCallbacks: Option[CustomConnectionCallbacks] = none(
    CustomConnectionCallbacks)): T:type {....raises: [].}
Source   Edit  
func outbound(p: PubSubPeer): bool {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc recvObservers(p: PubSubPeer; msg: var RPCMsg) {....raises: [],
    tags: [RootEffect], forbids: [].}
Source   Edit  
proc runHandleLoop(p: PubSubPeer; conn: Connection): InternalRaisesFuture[void,
    (CancelledError,)] {....stackTrace: false, raises: [], gcsafe, raises: [],
                         tags: [RootEffect], forbids: [].}
Source   Edit  
proc send(p: PubSubPeer; msg: RPCMsg; anonymize: bool; isHighPriority: bool;
          useCustomConn: bool = false) {....raises: [], raises: [],
    tags: [RootEffect, WriteIOEffect], forbids: [].}

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;
                 useCustomConn: bool = false): Future[void] {....raises: [],
    tags: [WriteIOEffect, RootEffect], forbids: [].}

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: [], forbids: [].}
Source   Edit  
proc stopSendNonPriorityTask(p: PubSubPeer) {....raises: [],
    tags: [WriteIOEffect, RootEffect], forbids: [].}
Source   Edit  
proc validatedObservers(p: PubSubPeer; msg: Message; msgId: MessageId) {.
    ...raises: [], tags: [RootEffect], forbids: [].}
Source   Edit  

Templates

template formatItIMPL(it: PubSubPeer): auto {..}
Source   Edit  

Exports

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