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

Commit

Permalink
fix: pass hasher loader to bitswap (#3944)
Browse files Browse the repository at this point in the history
To allow loading esoteric hashing algorithms encountered in CID prefixes found in bitswap messages, pass the configurable hasher loader to bitswap.
  • Loading branch information
achingbrain authored Nov 19, 2021
1 parent 605c83b commit f419553
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/ipfs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"hashlru": "^2.3.0",
"interface-blockstore": "^2.0.2",
"interface-datastore": "^6.0.2",
"ipfs-bitswap": "^7.0.0",
"ipfs-bitswap": "^7.0.1",
"ipfs-core-config": "^0.1.2",
"ipfs-core-types": "^0.8.2",
"ipfs-core-utils": "^0.12.0",
Expand Down
1 change: 1 addition & 0 deletions packages/ipfs-core/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class IPFS {
mfsPreload,
print,
keychain,
hashers: this.hashers,
options
})

Expand Down
8 changes: 6 additions & 2 deletions packages/ipfs-core/src/components/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { BlockStorage } from '../block-storage.js'
* @property {Repo} options.repo
* @property {Print} options.print
* @property {IPFSOptions} options.options
* @property {import('ipfs-core-utils/multihashes').Multihashes} options.hashers
*
* @typedef {import('ipfs-core-types/src/config').Config} IPFSConfig
* @typedef {import('../types').Options} IPFSOptions
Expand Down Expand Up @@ -44,7 +45,7 @@ export class Network {
/**
* @param {Options} options
*/
static async start ({ peerId, repo, print, options }) {
static async start ({ peerId, repo, print, hashers, options }) {
// Need to ensure that repo is open as it could have been closed between
// `init` and `start`.
if (repo.closed) {
Expand Down Expand Up @@ -73,7 +74,10 @@ export class Network {
print(`Swarm listening on ${ma}/p2p/${peerId.toB58String()}`)
}

const bitswap = createBitswap(libp2p, repo.blocks, { statsEnabled: true })
const bitswap = createBitswap(libp2p, repo.blocks, {
statsEnabled: true,
hashLoader: hashers
})
await bitswap.start()

const blockstore = new BlockStorage(repo.blocks, bitswap)
Expand Down
4 changes: 3 additions & 1 deletion packages/ipfs-core/src/components/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import { Service } from '../utils/service.js'
* @param {import('../types').MfsPreload} config.mfsPreload
* @param {import('./ipns').IPNSAPI} config.ipns
* @param {import('libp2p/src/keychain')} config.keychain
* @param {import('ipfs-core-utils/multihashes').Multihashes} config.hashers
* @param {import('../types').Options} config.options
*/
export function createStart ({ network, preload, peerId, keychain, repo, ipns, mfsPreload, print, options }) {
export function createStart ({ network, preload, peerId, keychain, repo, ipns, mfsPreload, print, hashers, options }) {
/**
* @type {import('ipfs-core-types/src/root').API["start"]}
*/
Expand All @@ -21,6 +22,7 @@ export function createStart ({ network, preload, peerId, keychain, repo, ipns, m
peerId,
repo,
print,
hashers,
options
})

Expand Down

0 comments on commit f419553

Please sign in to comment.