diff --git a/src/core/ipns/publisher.js b/src/core/ipns/publisher.js index c848ef3227..877d118815 100644 --- a/src/core/ipns/publisher.js +++ b/src/core/ipns/publisher.js @@ -40,7 +40,7 @@ class IpnsPublisher { return callback(err) } - this._putRecordToRouting(record, peerId, privKey, callback) + this._putRecordToRouting(record, peerId, callback) }) }) } @@ -50,7 +50,7 @@ class IpnsPublisher { this.publishWithEOL(privKey, value, defaultRecordTtl, callback) } - _putRecordToRouting (record, peerId, privKey, callback) { + _putRecordToRouting (record, peerId, callback) { if (!(peerId instanceof PeerId)) { const errMsg = `peerId received is not valid` @@ -74,10 +74,10 @@ class IpnsPublisher { } series([ - (cb) => this._publishEntry(keys.ipnsKey, embedPublicKeyRecord || record, peerId, privKey, cb), + (cb) => this._publishEntry(keys.ipnsKey, embedPublicKeyRecord || record, peerId, cb), // Publish the public key if a public key cannot be extracted from the ID // We will be able to deprecate this part in the future, since the public keys will be only in the peerId - (cb) => embedPublicKeyRecord ? this._publishPublicKey(keys.pkKey, publicKey, peerId, privKey, cb) : cb() + (cb) => embedPublicKeyRecord ? this._publishPublicKey(keys.pkKey, publicKey, peerId, cb) : cb() ], (err) => { if (err) { log.error(err) @@ -89,7 +89,7 @@ class IpnsPublisher { }) } - _publishEntry (key, entry, peerId, privKey, callback) { + _publishEntry (key, entry, peerId, callback) { if (!(key instanceof Key)) { const errMsg = `datastore key does not have a valid format` @@ -108,28 +108,21 @@ class IpnsPublisher { return callback(err) } - rec.serializeSigned(privKey, (err, serializedRecord) => { + // TODO Routing - this should be replaced by a put to the DHT + this._repo.datastore.put(key, rec.serialize(), (err, res) => { if (err) { - log.error(err) - return callback(err) - } - - // TODO Routing - this should be replaced by a put to the DHT - this._repo.datastore.put(key, serializedRecord, (err, res) => { - if (err) { - const errMsg = `ipns record for ${key.toString()} could not be stored in the routing` + const errMsg = `ipns record for ${key.toString()} could not be stored in the routing` - log.error(errMsg) - return callback(errcode(new Error(errMsg), 'ERR_STORING_IN_DATASTORE')) - } + log.error(errMsg) + return callback(errcode(new Error(errMsg), 'ERR_STORING_IN_DATASTORE')) + } - log(`ipns record for ${key.toString()} was stored in the routing`) - callback(null, res) - }) + log(`ipns record for ${key.toString()} was stored in the routing`) + callback(null, res) }) } - _publishPublicKey (key, publicKey, peerId, privKey, callback) { + _publishPublicKey (key, publicKey, peerId, callback) { if (!(key instanceof Key)) { const errMsg = `datastore key does not have a valid format` @@ -153,24 +146,17 @@ class IpnsPublisher { return callback(err) } - rec.serializeSigned(privKey, (err, serializedRecord) => { + // TODO Routing - this should be replaced by a put to the DHT + this._repo.datastore.put(key, rec.serialize(), (err, res) => { if (err) { - log.error(err) - return callback(err) - } - - // TODO Routing - this should be replaced by a put to the DHT - this._repo.datastore.put(key, serializedRecord, (err, res) => { - if (err) { - const errMsg = `public key for ${key.toString()} could not be stored in the routing` + const errMsg = `public key for ${key.toString()} could not be stored in the routing` - log.error(errMsg) - return callback(errcode(new Error(errMsg), 'ERR_STORING_IN_DATASTORE')) - } + log.error(errMsg) + return callback(errcode(new Error(errMsg), 'ERR_STORING_IN_DATASTORE')) + } - log(`public key for ${key.toString()} was stored in the routing`) - callback(null, res) - }) + log(`public key for ${key.toString()} was stored in the routing`) + callback(null, res) }) } diff --git a/src/core/ipns/resolver.js b/src/core/ipns/resolver.js index 525471a548..b70a1bf938 100644 --- a/src/core/ipns/resolver.js +++ b/src/core/ipns/resolver.js @@ -133,20 +133,13 @@ class IpnsResolver { return callback(err) } - // libp2p record signature validation - record.verifySignature(pubKey, (err) => { + // IPNS entry validation + ipns.validate(pubKey, ipnsEntry, (err) => { if (err) { return callback(err) } - // IPNS entry validation - ipns.validate(pubKey, ipnsEntry, (err) => { - if (err) { - return callback(err) - } - - callback(null, ipnsEntry.value.toString()) - }) + callback(null, ipnsEntry.value.toString()) }) }) })