Skip to content

Commit 579ddb5

Browse files
hacdiasdirkmc
authored andcommitted
fix: use multicodec correctly (#209)
License: MIT Signed-off-by: Henrique Dias <[email protected]>
1 parent 958c467 commit 579ddb5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"ipfs-block": "~0.8.0",
7878
"just-debounce-it": "^1.1.0",
7979
"moving-average": "^1.0.0",
80-
"multicodec": "~0.5.0",
80+
"multicodec": "~0.5.7",
8181
"multihashing-async": "^0.8.0",
8282
"protons": "^1.0.1",
8383
"pull-length-prefixed": "^1.3.1",

src/types/message/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const protons = require('protons')
44
const Block = require('ipfs-block')
55
const CID = require('cids')
6-
const codecName = require('multicodec/src/name-table')
6+
const { getName } = require('multicodec')
77
const vd = require('varint-decoder')
88
const multihashing = require('multihashing-async')
99
const { isMapEqual } = require('../../utils')
@@ -159,7 +159,7 @@ BitswapMessage.deserialize = async (raw) => {
159159
const hashAlg = values[2]
160160
// const hashLen = values[3] // We haven't need to use this so far
161161
const hash = await multihashing(p.data, hashAlg)
162-
const cid = new CID(cidVersion, codecName[multicodec.toString('16')], hash)
162+
const cid = new CID(cidVersion, getName(multicodec), hash)
163163
msg.addBlock(new Block(p.data, cid))
164164
}))
165165
return msg

0 commit comments

Comments
 (0)