From dfa2026afdbcc39deeec02be3e269f7906c515d6 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Mon, 12 Nov 2018 17:09:39 +0000 Subject: [PATCH] refactor: use peer id bytes instead of computing it again --- src/core/components/init.js | 3 ++- src/core/ipns/resolver.js | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/components/init.js b/src/core/components/init.js index eaa6644f7a..02da39b647 100644 --- a/src/core/components/init.js +++ b/src/core/components/init.js @@ -108,7 +108,8 @@ module.exports = function init (self) { cb(null, true) } }, - // Setup offline routing for IPNS. This is primarily used for offline ipns modifications, such as the initializeKeyspace feature. + // Setup the offline routing for IPNS. + // This is primarily used for offline ipns modifications, such as the initializeKeyspace feature. (_, cb) => { const offlineDatastore = new OfflineDatastore(self._repo) diff --git a/src/core/ipns/resolver.js b/src/core/ipns/resolver.js index 5c4ba538c8..56c8c813bb 100644 --- a/src/core/ipns/resolver.js +++ b/src/core/ipns/resolver.js @@ -1,7 +1,6 @@ 'use strict' const ipns = require('ipns') -const { fromB58String } = require('multihashes') const Record = require('libp2p-record').Record const PeerId = require('peer-id') const errcode = require('err-code') @@ -91,7 +90,7 @@ class IpnsResolver { // resolve ipns entries from the provided routing _resolveName (name, callback) { const peerId = PeerId.createFromB58String(name) - const { routingKey } = ipns.getIdKeys(fromB58String(name)) + const { routingKey } = ipns.getIdKeys(peerId.toBytes()) // TODO DHT - get public key from routing? // https://github.com/ipfs/go-ipfs/blob/master/namesys/routing.go#L70