Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

add filter functionality for multiaddr #63

Merged
merged 4 commits into from
Apr 9, 2018
Merged

Conversation

zcstarr
Copy link
Contributor

@zcstarr zcstarr commented Mar 11, 2018

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.

Copy link
Member

@daviddias daviddias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @zcstarr. The filter function on PeerInfo should not be just a simple array.filter, but rather an expansion of mafmt -- https://github.com/multiformats/js-mafmt.

@@ -52,6 +52,10 @@ class MultiaddrSet {
return this._multiaddrs.forEach(fn)
}

filter (fn) {
return this._multiaddrs.filter(fn)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package.json Outdated
@@ -44,8 +44,9 @@
"pre-commit": "^1.2.2"
},
"dependencies": {
"multiaddr": "^3.0.2",
"js-mafmt": "^1.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zcstarr the correct module name is mafmt

@daviddias daviddias merged commit 0dc8e03 into libp2p:master Apr 9, 2018
@ghost ghost removed the in progress label Apr 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants