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

Commit

Permalink
fix: use class is function on ipns (#1617)
Browse files Browse the repository at this point in the history
As `instance of` fails using different versions of a module, it was changed to use `class-is`.

Needs:

- [x] [js-peer-id#84](libp2p/js-peer-id#84)
- [x] [interface-datastore#24](ipfs/interface-datastore#24)

Fixes #1615
  • Loading branch information
vasco-santos authored and Alan Shaw committed Oct 29, 2018
1 parent 89ca551 commit c240d49
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"hapi-set-header": "^1.0.2",
"hoek": "^5.0.3",
"human-to-milliseconds": "^1.0.0",
"interface-datastore": "~0.5.0",
"interface-datastore": "~0.6.0",
"ipfs-api": "^24.0.0",
"ipfs-bitswap": "~0.20.3",
"ipfs-block": "~0.7.1",
Expand All @@ -111,7 +111,7 @@
"ipld": "~0.17.3",
"ipld-dag-cbor": "~0.12.1",
"ipld-dag-pb": "~0.14.6",
"ipns": "~0.2.0",
"ipns": "~0.3.0",
"is-ipfs": "~0.4.2",
"is-pull-stream": "~0.0.0",
"is-stream": "^1.1.0",
Expand Down Expand Up @@ -141,7 +141,7 @@
"multihashes": "~0.4.13",
"once": "^1.4.0",
"peer-book": "~0.8.0",
"peer-id": "~0.11.0",
"peer-id": "~0.12.0",
"peer-info": "~0.14.1",
"progress": "^2.0.0",
"promisify-es6": "^1.0.3",
Expand Down
10 changes: 5 additions & 5 deletions src/core/ipns/publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class IpnsPublisher {
}

_putRecordToRouting (record, peerId, callback) {
if (!(peerId instanceof PeerId)) {
if (!(PeerId.isPeerId(peerId))) {
const errMsg = `peerId received is not valid`

log.error(errMsg)
Expand Down Expand Up @@ -90,7 +90,7 @@ class IpnsPublisher {
}

_publishEntry (key, entry, peerId, callback) {
if (!(key instanceof Key)) {
if (!(Key.isKey(key))) {
const errMsg = `datastore key does not have a valid format`

log.error(errMsg)
Expand Down Expand Up @@ -123,7 +123,7 @@ class IpnsPublisher {
}

_publishPublicKey (key, publicKey, peerId, callback) {
if (!(key instanceof Key)) {
if ((!Key.isKey(key))) {
const errMsg = `datastore key does not have a valid format`

log.error(errMsg)
Expand Down Expand Up @@ -163,7 +163,7 @@ class IpnsPublisher {
// Returns the record this node has published corresponding to the given peer ID.
// If `checkRouting` is true and we have no existing record, this method will check the routing system for any existing records.
_getPublished (peerId, options, callback) {
if (!(peerId instanceof PeerId)) {
if (!(PeerId.isPeerId(peerId))) {
const errMsg = `peerId received is not valid`

log.error(errMsg)
Expand Down Expand Up @@ -216,7 +216,7 @@ class IpnsPublisher {
}

_updateOrCreateRecord (privKey, value, validity, peerId, callback) {
if (!(peerId instanceof PeerId)) {
if (!(PeerId.isPeerId(peerId))) {
const errMsg = `peerId received is not valid`

log.error(errMsg)
Expand Down
2 changes: 1 addition & 1 deletion src/core/ipns/republisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class IpnsRepublisher {
}

_getPreviousValue (peerId, callback) {
if (!(peerId instanceof PeerId)) {
if (!(PeerId.isPeerId(peerId))) {
const errMsg = `peerId received is not valid`

log.error(errMsg)
Expand Down

0 comments on commit c240d49

Please sign in to comment.