-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add put / get methods #54
Conversation
Hey @yusefnapora thanks for the PR ❤️ I have been thinking about namings given it feels strange to have them part of "Content Routing", when Content Routing is a "ContentRouting is a value provider layer of indirection. It is used to find information about who has what content.". Looking into go libp2p interface definitions, I think we should probably follow them here https://github.com/libp2p/go-libp2p-core/blob/master/routing/routing.go#L49-L68 . No strong opinion on naming, but for consistency probably Also for broader context here, when we did a DHT refactor a couple of years ago, we also created a distinction between content routing and put(get ops with |
I like Do you think that we should have a separate Then we can update js-libp2p's content-routing module to have both |
GIven we do not have typescript magic to easily see if X implements or not the interface, I think that is probably the best solution to what you suggest. However, it will require a libp2p breaking change to change configuration. I am ok with shipping this as a breaking change, but if you want to start by keeping things simple we can just inspect if the router has a put/get method for now. |
I realized that the reason I was getting errors passing I also realized that my IPNS test fixture record expires, so I made a new one with a > 100 year expiration date. @vasco-santos do you think the import DelegatedValueStore from 'libp2p-delegated-content-routing/src/value-store' I suppose we could export it from index.js instead, so you could do import DelegatedContentRouter, { DelegatedValueStore } from 'libp2p-delegated-content-routing' but that also feels a bit awkward. I'm not sure that's worth having one more repo to manage though. |
Yes, that require is not the best UX. We could create a breaking change here and return named exports as: import { DelegatedContentRouter, DelegatedValueStore } from 'libp2p-delegated-content-routing' or have everything in |
@yusefnapora will you have bandwidth to continue this work during this week's tribute? |
Moving this to draft until we're able to give a concerted effort on IPNS improvements as part of ipfs/js-ipfs#2921 |
Fixed in #68 |
This adds
put
andget
methods that wrap the client'sdht
methods.I noticed that it errors out if I pass in
Uint8Array
s todht.put
anddht.get
, so this will convert to string and complain if it's not given a valid UTF-8 key. Alternatively, we could just only accept strings, but this way we support the same argument types asdht.put
anddht.get
, so we can front them both with one interface.As for which interface, we could either expand the
ContentRouting
interface to includeput
andget
, or define a new one and just have theDelegatedContentRouter
implement both. Defining a new one seems a bit cleaner... maybeContentStorage
?@vasco-santos you seem like you'd have some thoughts on the interface question.
closes #49