-
Notifications
You must be signed in to change notification settings - Fork 60
Conversation
BREAKING CHANGE: The DHT now requires its datastore to have a promise based api, instead of callbacks. Datastores that use ipfs/[email protected] or later should be used. https://github.com/ipfs/interface-datastore/releases/tag/v0.7.0
some rules have been ignored until the full async/await migration has completed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great news! LGTM 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome Jacob!
Just found some minor issues with this
src/rpc/handlers/get-providers.js
Outdated
@@ -33,7 +33,7 @@ module.exports = (dht) => { | |||
const dsKey = utils.bufferToKey(cid.buffer) | |||
|
|||
parallel([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think on removing this async/parallel
and using Promise.all
with promisify
for dht._betterPeersToQuery(msg, peer, cb)
? We are converting to promises to callbacks here, and it would ease in the future to just remove the promisify from the last task
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can migrate the internals of this. I was originally trying to avoid touching too much other than the datastore, but I can go ahead and refactor this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a new getProvidersAsync
method that uses all the existing async methods, so no promisify is needed. getProviders
now calls that with promise-to-callback support, so when we refactor internally we can just do a full swap out of those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
BREAKING CHANGE: This change requires datastores that comply with [email protected] or later.
This refactors internal usage of
datastore
to use the async api. I also bumpedaegir
and fixed linting. Many of the rules forrequire-async
are ignored at the moment, they should be removed once the full conversion is done.Note: the libp2p-record update is the last dependency needed to convert to full async/await.