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

refactor: ipns routing logic moved to instantiation #1701

Merged
merged 4 commits into from
Nov 19, 2018

Conversation

vasco-santos
Copy link
Member

Currently, the ipns routing logic is inside the publish/ resolve logic.

Aiming to allow easily pluggable routings to ipns, I created this PR where the routing logic was moved from the ipns.publish / ipns.resolve to the instantiation of ipns.

With this, we can add a TieredDatastore to ipns with an array of datastores. This array can have the node repo's datastore, the DHT, the ipfs/js-datastore-pubsub, among others in the future. As a result, inside ipns logic, we will have routing.put and routing.get abstracted to all the enabled datastores.

The routing received by ipns will differ according to the node state. In the init and pre-start step, it will only receive the OfflineDatastore aka Repo's datastore. This is necessary to the offline features of IPNS, such as initializeKeyspace. Finally, in the end of the start step, that is, when all the services are running, ipns routing will have the mentioned TieredDatastore, containing all the intended datastores.

Moreover, the routing keys used to put records and public keys, where modified according to the new ones being used on go-ipfs

Note: this logic was implemented in ipfs/js-ipfs/pull/1559, which is currently blocked due to an interop problem with the topic (ipfs/interop#39). This way, I extracted this from that PR, in order to allow the implementation of IPNS over DHT. Once this is merged, I will also rebase the Pubsub PR with this, maintaing only the pubsub specific code in that PR.

@ghost ghost assigned vasco-santos Nov 7, 2018
@ghost ghost added the status/in-progress In progress label Nov 7, 2018
@vasco-santos
Copy link
Member Author

Tested ipfs/interop => 🍏

@vasco-santos vasco-santos changed the title [WIP] chore: ipns routing logic moved to instantiation chore: ipns routing logic moved to instantiation Nov 7, 2018
@vasco-santos vasco-santos force-pushed the chore/ipns-routing-moved-to-instantiation branch from 9f7fb87 to 73d3686 Compare November 11, 2018 02:36
src/core/ipns/resolver.js Outdated Show resolved Hide resolved
@vasco-santos vasco-santos force-pushed the chore/ipns-routing-moved-to-instantiation branch 2 times, most recently from 1c98e7d to 5a07d44 Compare November 13, 2018 10:08
@vasco-santos vasco-santos mentioned this pull request Nov 14, 2018
Copy link
Contributor

@fsdiogo fsdiogo left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@vasco-santos vasco-santos force-pushed the chore/ipns-routing-moved-to-instantiation branch from 5a07d44 to 8c3b843 Compare November 14, 2018 15:51
Copy link
Member

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

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

Looks like the tests in /test/core/name.js aren't being run - can you please add them to /test/core/node.js so they do?

Can you look into addressing the coverage for src/core/ipns?:

screenshot 2018-11-16 at 14 39 46

package.json Outdated Show resolved Hide resolved
src/core/components/pre-start.js Outdated Show resolved Hide resolved
src/core/components/start.js Outdated Show resolved Hide resolved
src/core/ipns/resolver.js Outdated Show resolved Hide resolved
src/core/ipns/index.js Show resolved Hide resolved
src/core/ipns/resolver.js Outdated Show resolved Hide resolved
src/core/ipns/resolver.js Outdated Show resolved Hide resolved
src/core/ipns/routing/offline-datastore.js Outdated Show resolved Hide resolved
src/core/ipns/routing/offline-datastore.js Outdated Show resolved Hide resolved
src/core/ipns/routing/offline-datastore.js Show resolved Hide resolved
@alanshaw
Copy link
Member

P.S. commit message prefixes should be "refactor: " for this ;)

@alanshaw alanshaw changed the title chore: ipns routing logic moved to instantiation refactor: ipns routing logic moved to instantiation Nov 16, 2018
@vasco-santos vasco-santos force-pushed the chore/ipns-routing-moved-to-instantiation branch 6 times, most recently from 538ff23 to b25bcc1 Compare November 17, 2018 00:44
@vasco-santos
Copy link
Member Author

@alanshaw addressed your review, changed the commit message prefix and added a bunch of tests to the /core/ipns.

@vasco-santos vasco-santos force-pushed the chore/ipns-routing-moved-to-instantiation branch from b25bcc1 to fa1d79c Compare November 17, 2018 01:00
@@ -98,16 +100,16 @@ class IpnsRepublisher {
}

// keychain needs pass to get the cryptographic keys
if (this._ipfs._keychain && Boolean(pass)) {
this._ipfs._keychain.listKeys((err, list) => {
if (this._keychain && Boolean(pass)) {
Copy link
Member

Choose a reason for hiding this comment

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

Can this._keychain be null?

src/core/ipns/resolver.js Show resolved Hide resolved
src/core/ipns/resolver.js Outdated Show resolved Hide resolved
src/core/ipns/resolver.js Outdated Show resolved Hide resolved
src/core/ipns/routing/utils.js Outdated Show resolved Hide resolved
@vasco-santos vasco-santos force-pushed the chore/ipns-routing-moved-to-instantiation branch from a66deba to 5f95002 Compare November 19, 2018 11:01
@vasco-santos vasco-santos force-pushed the chore/ipns-routing-moved-to-instantiation branch from 5f95002 to ade2d1c Compare November 19, 2018 16:06
@alanshaw
Copy link
Member

@vasco-santos would you mind rebasing this now the pin fixes are in?

@vasco-santos
Copy link
Member Author

It is already running the CI rebased 😀

@alanshaw alanshaw merged commit a0642ed into master Nov 19, 2018
@ghost ghost removed the status/in-progress In progress label Nov 19, 2018
@alanshaw alanshaw deleted the chore/ipns-routing-moved-to-instantiation branch November 19, 2018 18:22
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.

3 participants