• Creates a PeerSet that reports it's size to the libp2p Metrics service

    Parameters

    Returns PeerSet

    Example: Tracked peer sets

    • 
      

    import { trackedPeerSet } from '@libp2p/peer-collections' import { createLibp2p } from 'libp2p'

    const libp2p = await createLibp2p()

    const list = trackedPeerSet({ name: 'my_metric_name', metrics: libp2p.metrics }) map.add(peerId) ```