libp2p
    Preparing search index...
    • Create and return a PeerFilter. This can be used by topologies to prevent them receiving duplicate notifications for a peer that connects repeatedly.

      Parameters

      • size: number

        The maximum number of peers expected to be added to the filter

      • errorRate: number = 0.001

        The acceptable error rate

      Returns PeerFilter

      import { peerFilter } from '@libp2p/peer-collections'
      import type { Registrar } from '@libp2p/interface-internal'

      const registrar: Registrar

      registrar.register('/my/protocol/1.0.0', {
      filter: peerFilter(),
      onConnect: (peerId) => {
      // will only be invoked for a given peerId once
      }
      })