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

Commit f419553

Browse files
authoredNov 19, 2021
fix: pass hasher loader to bitswap (#3944)
To allow loading esoteric hashing algorithms encountered in CID prefixes found in bitswap messages, pass the configurable hasher loader to bitswap.
1 parent 605c83b commit f419553

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed
 

‎packages/ipfs-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"hashlru": "^2.3.0",
8484
"interface-blockstore": "^2.0.2",
8585
"interface-datastore": "^6.0.2",
86-
"ipfs-bitswap": "^7.0.0",
86+
"ipfs-bitswap": "^7.0.1",
8787
"ipfs-core-config": "^0.1.2",
8888
"ipfs-core-types": "^0.8.2",
8989
"ipfs-core-utils": "^0.12.0",

‎packages/ipfs-core/src/components/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class IPFS {
155155
mfsPreload,
156156
print,
157157
keychain,
158+
hashers: this.hashers,
158159
options
159160
})
160161

‎packages/ipfs-core/src/components/network.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { BlockStorage } from '../block-storage.js'
1414
* @property {Repo} options.repo
1515
* @property {Print} options.print
1616
* @property {IPFSOptions} options.options
17+
* @property {import('ipfs-core-utils/multihashes').Multihashes} options.hashers
1718
*
1819
* @typedef {import('ipfs-core-types/src/config').Config} IPFSConfig
1920
* @typedef {import('../types').Options} IPFSOptions
@@ -44,7 +45,7 @@ export class Network {
4445
/**
4546
* @param {Options} options
4647
*/
47-
static async start ({ peerId, repo, print, options }) {
48+
static async start ({ peerId, repo, print, hashers, options }) {
4849
// Need to ensure that repo is open as it could have been closed between
4950
// `init` and `start`.
5051
if (repo.closed) {
@@ -73,7 +74,10 @@ export class Network {
7374
print(`Swarm listening on ${ma}/p2p/${peerId.toB58String()}`)
7475
}
7576

76-
const bitswap = createBitswap(libp2p, repo.blocks, { statsEnabled: true })
77+
const bitswap = createBitswap(libp2p, repo.blocks, {
78+
statsEnabled: true,
79+
hashLoader: hashers
80+
})
7781
await bitswap.start()
7882

7983
const blockstore = new BlockStorage(repo.blocks, bitswap)

‎packages/ipfs-core/src/components/start.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import { Service } from '../utils/service.js'
1010
* @param {import('../types').MfsPreload} config.mfsPreload
1111
* @param {import('./ipns').IPNSAPI} config.ipns
1212
* @param {import('libp2p/src/keychain')} config.keychain
13+
* @param {import('ipfs-core-utils/multihashes').Multihashes} config.hashers
1314
* @param {import('../types').Options} config.options
1415
*/
15-
export function createStart ({ network, preload, peerId, keychain, repo, ipns, mfsPreload, print, options }) {
16+
export function createStart ({ network, preload, peerId, keychain, repo, ipns, mfsPreload, print, hashers, options }) {
1617
/**
1718
* @type {import('ipfs-core-types/src/root').API["start"]}
1819
*/
@@ -21,6 +22,7 @@ export function createStart ({ network, preload, peerId, keychain, repo, ipns, m
2122
peerId,
2223
repo,
2324
print,
25+
hashers,
2426
options
2527
})
2628

0 commit comments

Comments
 (0)
This repository has been archived.