Hierarchy

  • GossipSub
    • IRelay

Properties

#private: any
addObserver: (<T>(decoder: IDecoder<T>, callback: Callback<T>) => (() => void))

Type declaration

control: Map<string, IControlMessage>

Map of control messages peer id => control message

direct: Set<string>

Direct peers

fanout: Map<string, Set<string>>

Map of topics to set of peers. These mesh peers are the ones to which we are publishing without a topic membership topic => peer id set

getMeshPeers: (() => string[])

Type declaration

    • (): string[]
    • Returns string[]

globalSignaturePolicy: "StrictSign" | "StrictNoSign"

The signature policy to follow by default

gossip: Map<string, IControlIHave[]>

Map of pending messages to gossip peer id => control messages

gossipTracer: IWantTracer

Tracks IHAVE/IWANT promises broken by peers

mesh: Map<string, Set<string>>

Map of topic meshes topic => peer id set

multicodecs: string[]
opts: Required<GossipOptions>
peers: Set<string>
score: PeerScore

Peer score tracking

send: ((encoder: IEncoder, message: IMessage) => Promise<SendResult>)

Type declaration

streamsInbound: Map<string, InboundStream>
streamsOutbound: Map<string, OutboundStream>
topicValidators: Map<string, TopicValidatorFn>

Custom validator function per topic. Must return or resolve quickly (< 100ms) to prevent causing penalties for late messages. If you need to apply validation that may require longer times use asyncValidation option and callback the validation result through Gossipsub.reportValidationResult

Accessors

  • get started(): boolean
  • Returns boolean

Methods

  • Whether to accept a message from a peer

    Parameters

    • id: string

    Returns boolean

  • Type Parameters

    • K extends keyof GossipsubEvents

    Parameters

    • type: K
    • listener: null | EventHandler<GossipsubEvents[K]>
    • Optional options: boolean | AddEventListenerOptions

    Returns void

  • Parameters

    • event: Event

    Returns boolean

  • FOR DEBUG ONLY - Dump peer stats for all peers. Data is cloned, safe to mutate

    Returns PeerScoreStatsDump

  • Returns PeerId[]

  • Return score of a peer.

    Parameters

    • peerId: string

    Returns number

  • Get a list of the peer-ids that are subscribed to one topic.

    Parameters

    • topic: string

    Returns PeerId[]

  • Get the list of topics which the peer is subscribed to.

    Returns string[]

  • Handles an rpc request from a peer

    Parameters

    • from: PeerId
    • rpc: IRPC

    Returns Promise<void>

  • Maintains the mesh and fanout maps in gossipsub.

    Returns Promise<void>

  • Returns boolean

  • Parameters

    • type: string

    Returns number

  • Mutates outRpc adding graft and prune control messages

    Parameters

    • id: string
    • outRpc: IRPC
    • ctrl: IControlMessage

    Returns void

  • App layer publishes a message to peers, return number of peers this message is published to Note: async due to crypto only if StrictSign, otherwise it's a sync fn.

    For messages not from us, this class uses forwardMessage.

    Parameters

    • topic: string
    • data: Uint8Array

    Returns Promise<PublishResult>

  • Type Parameters

    • K extends keyof GossipsubEvents

    Parameters

    • type: K
    • Optional listener: null | EventHandler<GossipsubEvents[K]>
    • Optional options: boolean | EventListenerOptions

    Returns void

  • This function should be called when asyncValidation is true after the message got validated by the caller. Messages are stored in the mcache and validation is expected to be fast enough that the messages should still exist in the cache. There are three possible validation outcomes and the outcome is given in acceptance.

    If acceptance = MessageAcceptance.Accept the message will get propagated to the network. The propagation_source parameter indicates who the message was received by and will not be forwarded back to that peer.

    If acceptance = MessageAcceptance.Reject the message will be deleted from the memcache and the P₄ penalty will be applied to the propagationSource.

    If acceptance = MessageAcceptance.Ignore the message will be deleted from the memcache but no P₄ penalty will be applied.

    This function will return true if the message was found in the cache and false if was not in the cache anymore.

    This should only be called once per message.

    Parameters

    • msgId: string
    • propagationSource: PeerId
    • acceptance: TopicValidatorResult

    Returns void

  • Mounts the gossipsub protocol onto the libp2p node and sends our our subscriptions to every peer connected

    Returns Promise<void>

  • Unmounts the gossipsub protocol and shuts down every connection

    Returns Promise<void>

  • Subscribes to a topic

    Parameters

    • topic: string

    Returns void

  • Unsubscribe to a topic

    Parameters

    • topic: string

    Returns void

Generated using TypeDoc