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

fix: use Key.asKey instead of instanceOf #3877

Merged
merged 3 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
fetch-depth: ${{ github.event.pull_request.commits }}
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
fetch-depth: ${{ github.event.pull_request.commits }}
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: 16
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
fetch-depth: ${{ github.event.pull_request.commits }}
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: 16
Expand Down Expand Up @@ -167,7 +167,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
fetch-depth: ${{ github.event.pull_request.commits }}
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: 16
Expand Down Expand Up @@ -205,7 +205,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
fetch-depth: ${{ github.event.pull_request.commits }}
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: 16
Expand Down Expand Up @@ -246,7 +246,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
fetch-depth: ${{ github.event.pull_request.commits }}
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: 16
Expand Down Expand Up @@ -275,7 +275,7 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
fetch-depth: ${{ github.event.pull_request.commits }}
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: 16
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-core-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
],
"license": "(Apache-2.0 OR MIT)",
"dependencies": {
"interface-datastore": "^5.0.0",
"interface-datastore": "^5.2.0",
"multiaddr": "^10.0.0",
"multiformats": "^9.4.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"hamt-sharding": "^2.0.0",
"hashlru": "^2.3.0",
"interface-blockstore": "^1.0.0",
"interface-datastore": "^5.0.0",
"interface-datastore": "^5.2.0",
"ipfs-bitswap": "^6.0.0",
"ipfs-core-types": "^0.7.2",
"ipfs-core-utils": "^0.10.4",
Expand Down
20 changes: 12 additions & 8 deletions packages/ipfs-core/src/ipns/publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ class IpnsPublisher {
* @param {IPNSEntry} entry
*/
async _publishEntry (key, entry) {
if (!(key instanceof Key)) {
const k = Key.asKey(key)

if (!k) {
const errMsg = 'datastore key does not have a valid format'

log.error(errMsg)
Expand All @@ -112,12 +114,12 @@ class IpnsPublisher {

// Add record to routing (buffer key)
try {
const res = await this._routing.put(key.uint8Array(), entryData)
log(`ipns record for ${uint8ArrayToString(key.uint8Array(), 'base64')} was stored in the routing`)
const res = await this._routing.put(k.uint8Array(), entryData)
log(`ipns record for ${uint8ArrayToString(k.uint8Array(), 'base64')} was stored in the routing`)

return res
} catch (err) {
const errMsg = `ipns record for ${uint8ArrayToString(key.uint8Array(), 'base64')} could not be stored in the routing`
const errMsg = `ipns record for ${uint8ArrayToString(k.uint8Array(), 'base64')} could not be stored in the routing`
log.error(errMsg)
log.error(err)

Expand All @@ -130,7 +132,9 @@ class IpnsPublisher {
* @param {PublicKey} publicKey
*/
async _publishPublicKey (key, publicKey) {
if (!(key instanceof Key)) {
const k = Key.asKey(key)

if (!k) {
const errMsg = 'datastore key does not have a valid format'
log.error(errMsg)

Expand All @@ -146,12 +150,12 @@ class IpnsPublisher {

// Add public key to routing (buffer key)
try {
const res = await this._routing.put(key.uint8Array(), publicKey.bytes)
log(`public key for ${uint8ArrayToString(key.uint8Array(), 'base64')} was stored in the routing`)
const res = await this._routing.put(k.uint8Array(), publicKey.bytes)
log(`public key for ${uint8ArrayToString(k.uint8Array(), 'base64')} was stored in the routing`)

return res
} catch (err) {
const errMsg = `public key for ${uint8ArrayToString(key.uint8Array(), 'base64')} could not be stored in the routing`
const errMsg = `public key for ${uint8ArrayToString(k.uint8Array(), 'base64')} could not be stored in the routing`
log.error(errMsg)
log.error(err)

Expand Down