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

    Type Parameters

    • V

    Parameters

    Returns PeerMap<V>

    Example

    • 
      

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

    const libp2p = await createLibp2p()

    const list = trackedPeerMap({ name: 'my_metric_name', metrics: libp2p.metrics }) map.set(peerId, 'value') ```