libp2p / js-peer-info

libp2p Peer abstraction Node.js implementation
https://libp2p.io
MIT License
37 stars 28 forks source link

add filter functionality for multiaddr #63

Closed zcstarr closed 6 years ago

zcstarr commented 6 years ago

This is in regards to #7 , it seems like adding a filter capability to multiaddrs in PeerInfo would be a step in the right direction, maybe all that's really needed. Downstream request become something like

pInfo.multiaddrs.filter((ma)=>mafmt.UDP.matches(ma)) 

For more complex slices it seems as though maybe js-mafmt should expose or/and, so people can define their own valid slices of protocols, then refer to them as needed if that make sense. @diasdavid what do you think, not sure if this is inline with what you had in mind :), open to suggestions thoughts.