From 38c9f19929e7d3228d748c9d734e129c5ab29e47 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Wed, 7 Nov 2018 11:47:43 +0000 Subject: [PATCH] refactor: ipns routing logic moved to instantiation --- package.json | 1 + src/core/components/pre-start.js | 11 +++++++++++ src/core/ipns/routing/offline-datastore.js | 3 +++ 3 files changed, 15 insertions(+) diff --git a/package.json b/package.json index 723da697c4..e57be61e8a 100644 --- a/package.json +++ b/package.json @@ -80,6 +80,7 @@ "dependencies": { "@nodeutils/defaults-deep": "^1.1.0", "async": "^2.6.1", + "base32.js": "~0.1.0", "big.js": "^5.2.2", "binary-querystring": "~0.1.2", "bl": "^2.1.2", diff --git a/src/core/components/pre-start.js b/src/core/components/pre-start.js index 13d914acc4..9914a8167e 100644 --- a/src/core/components/pre-start.js +++ b/src/core/components/pre-start.js @@ -7,6 +7,10 @@ const waterfall = require('async/waterfall') const Keychain = require('libp2p-keychain') const defaultsDeep = require('@nodeutils/defaults-deep') const NoKeychain = require('./no-keychain') + +const IPNS = require('../ipns') +const OfflineDatastore = require('../ipns/routing/offline-datastore') + /* * Load stuff from Repo into memory */ @@ -95,6 +99,13 @@ module.exports = function preStart (self) { cb() }, + // Setup offline routing for IPNS. + (cb) => { + const offlineDatastore = new OfflineDatastore(self._repo) + + self._ipns = new IPNS(offlineDatastore, self) + cb() + }, (cb) => self.pin._load(cb) ], callback) } diff --git a/src/core/ipns/routing/offline-datastore.js b/src/core/ipns/routing/offline-datastore.js index 26de52528c..bdfb67a63e 100644 --- a/src/core/ipns/routing/offline-datastore.js +++ b/src/core/ipns/routing/offline-datastore.js @@ -3,11 +3,14 @@ const { Key } = require('interface-datastore') const { encodeBase32 } = require('./utils') +<<<<<<< HEAD const errcode = require('err-code') const debug = require('debug') const log = debug('jsipfs:ipns:offline-datastore') log.error = debug('jsipfs:ipns:offline-datastore:error') +======= +>>>>>>> refactor: ipns routing logic moved to instantiation // Offline datastore aims to mimic the same encoding as routing when storing records // to the local datastore class OfflineDatastore {