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

Commit 3641403

Browse files
committed
chore: update datastore implemenations
Pulls in esm versions of datastore/blockstore. Also ipfs-repo, bitswap, ipns, etc.
1 parent be4a542 commit 3641403

35 files changed

+103
-105
lines changed

packages/interface-ipfs-core/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"@types/readable-stream": "^2.3.11",
6969
"abort-controller": "^3.0.0",
7070
"aegir": "^35.1.0",
71+
"blockstore-core": "^1.0.2",
7172
"copyfiles": "^2.4.1",
7273
"delay": "^5.0.0",
7374
"err-code": "^3.0.1",
@@ -76,7 +77,7 @@
7677
"ipfs-unixfs": "^6.0.3",
7778
"ipfs-unixfs-importer": "^9.0.3",
7879
"ipfs-utils": "^9.0.1",
79-
"ipns": "^0.14.0",
80+
"ipns": "^0.15.0",
8081
"is-ipfs": "^6.0.1",
8182
"iso-random-stream": "^2.0.0",
8283
"it-all": "^1.0.4",

packages/interface-ipfs-core/src/name-pubsub/pubsub.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { expect } from 'aegir/utils/chai.js'
44
import { getDescribe, getIt } from '../utils/mocha.js'
55
import PeerId from 'peer-id'
66
import { isNode } from 'ipfs-utils/src/env.js'
7-
import ipns from 'ipns'
7+
import * as ipns from 'ipns'
88
import delay from 'delay'
99
import last from 'it-last'
1010
import waitFor from '../utils/wait-for.js'

packages/interface-ipfs-core/src/utils/blockstore-adapter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BlockstoreAdapter } from 'interface-blockstore'
1+
import { BaseBlockstore } from 'blockstore-core/base'
22
import * as raw from 'multiformats/codecs/raw'
33
import * as dagPB from '@ipld/dag-pb'
44
import * as dagCBOR from '@ipld/dag-cbor'
@@ -21,7 +21,7 @@ const hashes = {
2121
[sha256.code]: sha256.name
2222
}
2323

24-
class IPFSBlockstore extends BlockstoreAdapter {
24+
class IPFSBlockstore extends BaseBlockstore {
2525
/**
2626
* @param {import('ipfs-core-types').IPFS} ipfs
2727
*/

packages/ipfs-cli/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@
7070
"ipfs-core-utils": "^0.10.5",
7171
"ipfs-daemon": "^0.9.8",
7272
"ipfs-http-client": "^52.0.5",
73-
"ipfs-repo": "^12.0.0",
73+
"ipfs-repo": "^13.0.4",
7474
"ipfs-utils": "^9.0.1",
7575
"it-all": "^1.0.4",
7676
"it-concat": "^2.0.0",
7777
"it-first": "^1.0.4",
78-
"it-glob": "1.0.0",
78+
"it-glob": "^1.0.0",
7979
"it-map": "^1.0.5",
8080
"it-merge": "^1.0.3",
8181
"it-pipe": "^1.1.0",

packages/ipfs-core-config/package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,16 @@
8080
"license": "MIT",
8181
"dependencies": {
8282
"@chainsafe/libp2p-noise": "^4.0.0",
83-
"blockstore-datastore-adapter": "^1.0.2",
84-
"datastore-core": "^5.0.1",
85-
"datastore-fs": "^5.0.2",
86-
"datastore-level": "^6.0.2",
83+
"blockstore-datastore-adapter": "^2.0.2",
84+
"datastore-core": "^6.0.7",
85+
"datastore-fs": "^6.0.1",
86+
"datastore-level": "^7.0.1",
8787
"debug": "^4.1.1",
8888
"err-code": "^3.0.1",
8989
"hashlru": "^2.3.0",
90-
"ipfs-repo": "^12.0.0",
90+
"ipfs-repo": "^13.0.4",
9191
"ipfs-utils": "^9.0.1",
92-
"ipns": "^0.14.0",
92+
"ipns": "^0.15.0",
9393
"is-ipfs": "^6.0.1",
9494
"it-all": "^1.0.4",
9595
"it-drain": "^1.0.3",

packages/ipfs-core-config/src/repo.browser.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
21
import { createRepo as create } from 'ipfs-repo'
3-
import DatastoreLevel from 'datastore-level'
4-
import BlockstoreDatastoreAdapter from 'blockstore-datastore-adapter'
2+
import { LevelDatastore } from 'datastore-level'
3+
import { BlockstoreDatastoreAdapter } from 'blockstore-datastore-adapter'
4+
import { MemoryLock } from 'ipfs-repo/locks/memory'
55

66
/**
77
* @typedef {import('ipfs-repo-migrations').ProgressCallback} MigrationProgressCallback
@@ -19,30 +19,31 @@ export function createRepo (print, codecs, options) {
1919
const repoPath = options.path || 'ipfs'
2020

2121
return create(repoPath, (codeOrName) => codecs.getCodec(codeOrName), {
22-
root: new DatastoreLevel(repoPath, {
22+
root: new LevelDatastore(repoPath, {
2323
prefix: '',
2424
version: 2
2525
}),
2626
blocks: new BlockstoreDatastoreAdapter(
27-
new DatastoreLevel(`${repoPath}/blocks`, {
27+
new LevelDatastore(`${repoPath}/blocks`, {
2828
prefix: '',
2929
version: 2
3030
})
3131
),
32-
datastore: new DatastoreLevel(`${repoPath}/datastore`, {
32+
datastore: new LevelDatastore(`${repoPath}/datastore`, {
3333
prefix: '',
3434
version: 2
3535
}),
36-
keys: new DatastoreLevel(`${repoPath}/keys`, {
36+
keys: new LevelDatastore(`${repoPath}/keys`, {
3737
prefix: '',
3838
version: 2
3939
}),
40-
pins: new DatastoreLevel(`${repoPath}/pins`, {
40+
pins: new LevelDatastore(`${repoPath}/pins`, {
4141
prefix: '',
4242
version: 2
4343
})
4444
}, {
4545
autoMigrate: options.autoMigrate,
46-
onMigrationProgress: options.onMigrationProgress || print
46+
onMigrationProgress: options.onMigrationProgress || print,
47+
repoLock: MemoryLock
4748
})
4849
}

packages/ipfs-core-config/src/repo.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import os from 'os'
33
import { createRepo as create } from 'ipfs-repo'
44
import path from 'path'
5-
import DatastoreFS from 'datastore-fs'
6-
import DatastoreLevel from 'datastore-level'
7-
import BlockstoreDatastoreAdapter from 'blockstore-datastore-adapter'
8-
import { ShardingDatastore, shard } from 'datastore-core'
9-
10-
const { NextToLast } = shard
5+
import { FsDatastore } from 'datastore-fs'
6+
import { LevelDatastore } from 'datastore-level'
7+
import { BlockstoreDatastoreAdapter } from 'blockstore-datastore-adapter'
8+
import { ShardingDatastore } from 'datastore-core/sharding'
9+
import { NextToLast } from 'datastore-core/shard'
10+
import { FSLock } from 'ipfs-repo/locks/fs'
1111

1212
/**
1313
* @typedef {import('ipfs-repo-migrations').ProgressCallback} MigrationProgressCallback
@@ -42,22 +42,23 @@ export function createRepo (print, codecs, options = {}) {
4242
}
4343

4444
return create(repoPath, (codeOrName) => codecs.getCodec(codeOrName), {
45-
root: new DatastoreFS(repoPath, {
45+
root: new FsDatastore(repoPath, {
4646
extension: ''
4747
}),
4848
blocks: new BlockstoreDatastoreAdapter(
4949
new ShardingDatastore(
50-
new DatastoreFS(`${repoPath}/blocks`, {
50+
new FsDatastore(`${repoPath}/blocks`, {
5151
extension: '.data'
5252
}),
5353
new NextToLast(2)
5454
)
5555
),
56-
datastore: new DatastoreLevel(`${repoPath}/datastore`),
57-
keys: new DatastoreFS(`${repoPath}/keys`),
58-
pins: new DatastoreLevel(`${repoPath}/pins`)
56+
datastore: new LevelDatastore(`${repoPath}/datastore`),
57+
keys: new FsDatastore(`${repoPath}/keys`),
58+
pins: new LevelDatastore(`${repoPath}/pins`)
5959
}, {
6060
autoMigrate: options.autoMigrate != null ? options.autoMigrate : true,
61-
onMigrationProgress: onMigrationProgress
61+
onMigrationProgress: onMigrationProgress,
62+
repoLock: FSLock
6263
})
6364
}

packages/ipfs-core-config/src/utils/ipns.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
import ipns from 'ipns'
1+
import * as ipns from 'ipns'
32

43
export const validator = {
54
/**

packages/ipfs-core-types/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
],
4545
"license": "(Apache-2.0 OR MIT)",
4646
"dependencies": {
47-
"interface-datastore": "^5.2.0",
47+
"interface-datastore": "^6.0.2",
4848
"multiaddr": "^10.0.0",
4949
"multiformats": "^9.4.1"
5050
},

packages/ipfs-core-utils/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
"any-signal": "^2.1.2",
110110
"blob-to-it": "^1.0.1",
111111
"browser-readablestream-to-it": "^1.0.1",
112+
"debug": "^4.1.1",
112113
"err-code": "^3.0.1",
113114
"ipfs-core-types": "^0.7.3",
114115
"ipfs-unixfs": "^6.0.3",

packages/ipfs-core-utils/src/multipart-request.node.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import { modeToString } from './mode-to-string.js'
55
import mergeOpts from 'merge-options'
66
// @ts-expect-error no types
77
import toStream from 'it-to-stream'
8+
import debug from 'debug'
89

910
const merge = mergeOpts.bind({ ignoreUndefined: true })
11+
const log = debug('ipfs:core-utils:multipart-request')
1012

1113
/**
1214
* @typedef {import('ipfs-core-types/src/utils').ImportCandidateStream} ImportCandidateStream
@@ -70,7 +72,8 @@ export async function multipartRequest (source, abortController, headers = {}, b
7072

7173
index++
7274
}
73-
} catch {
75+
} catch (err) {
76+
log(err)
7477
// workaround for https://github.com/node-fetch/node-fetch/issues/753
7578
abortController.abort()
7679
} finally {

packages/ipfs-core/package.json

+18-13
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"test:electron-renderer": "aegir build --esm-tests && aegir test -t electron-renderer -f ./dist/cjs/browser-test/*.spec.js",
6363
"test:bootstrapers": "IPFS_TEST=bootstrapers aegir test -t browser -f test/bootstrapers.js",
6464
"clean": "rimraf ./dist",
65-
"dep-check": "aegir dep-check -i interface-ipfs-core -i ipfs-core-types -i abort-controller -i npm-run-all"
65+
"dep-check": "aegir dep-check -i interface-ipfs-core -i ipfs-core-types -i abort-controller -i npm-run-all --i interface-blockstore"
6666
},
6767
"dependencies": {
6868
"@chainsafe/libp2p-noise": "^4.0.0",
@@ -72,27 +72,29 @@
7272
"@multiformats/murmur3": "^1.0.1",
7373
"any-signal": "^2.1.2",
7474
"array-shuffle": "^2.0.0",
75-
"blockstore-datastore-adapter": "^1.0.2",
76-
"datastore-core": "^5.0.1",
77-
"datastore-pubsub": "^0.7.0",
75+
"blockstore-core": "^1.0.2",
76+
"blockstore-datastore-adapter": "^2.0.2",
77+
"datastore-core": "^6.0.7",
78+
"datastore-fs": "^6.0.1",
79+
"datastore-level": "^7.0.1",
80+
"datastore-pubsub": "^1.0.0",
7881
"debug": "^4.1.1",
7982
"dlv": "^1.1.3",
8083
"err-code": "^3.0.1",
8184
"hamt-sharding": "^2.0.0",
8285
"hashlru": "^2.3.0",
83-
"interface-blockstore": "^1.0.0",
84-
"interface-datastore": "^5.2.0",
85-
"ipfs-bitswap": "^6.0.0",
86-
"ipfs-core-config": "^0.0.1",
86+
"interface-blockstore": "^2.0.2",
87+
"interface-datastore": "^6.0.2",
88+
"ipfs-bitswap": "^7.0.0",
8789
"ipfs-core-types": "^0.7.3",
8890
"ipfs-core-utils": "^0.10.5",
8991
"ipfs-http-client": "^52.0.5",
90-
"ipfs-repo": "^12.0.0",
92+
"ipfs-repo": "^13.0.4",
9193
"ipfs-unixfs": "^6.0.3",
9294
"ipfs-unixfs-exporter": "^7.0.3",
9395
"ipfs-unixfs-importer": "^9.0.3",
94-
"ipfs-utils": "^9.0.1",
95-
"ipns": "^0.14.0",
96+
"ipfs-utils": "^8.1.4",
97+
"ipns": "^0.15.0",
9698
"is-domain-name": "^1.0.1",
9799
"is-ipfs": "^6.0.1",
98100
"it-all": "^1.0.4",
@@ -109,12 +111,15 @@
109111
"it-tar": "^4.0.0",
110112
"it-to-buffer": "^2.0.0",
111113
"just-safe-set": "^2.2.1",
112-
"libp2p": "^0.32.0",
114+
"libp2p": "^0.33.0",
113115
"libp2p-bootstrap": "^0.13.0",
114116
"libp2p-crypto": "^0.19.7",
115117
"libp2p-delegated-content-routing": "^0.11.0",
116118
"libp2p-delegated-peer-routing": "^0.10.0",
117119
"libp2p-gossipsub": "^0.11.1",
120+
"libp2p-kad-dht": "^0.25.0",
121+
"libp2p-mdns": "^0.17.0",
122+
"libp2p-mplex": "^0.10.2",
118123
"libp2p-record": "^0.10.3",
119124
"mafmt": "^10.0.0",
120125
"merge-options": "^3.0.4",
@@ -136,7 +141,7 @@
136141
"aegir": "^35.1.0",
137142
"delay": "^5.0.0",
138143
"go-ipfs": "0.9.1",
139-
"interface-blockstore-tests": "^1.0.0",
144+
"interface-blockstore-tests": "^2.0.1",
140145
"interface-ipfs-core": "^0.150.4",
141146
"ipfsd-ctl": "^10.0.3",
142147
"iso-url": "^1.0.0",

packages/ipfs-core/src/block-storage.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
import { BlockstoreAdapter } from 'interface-blockstore'
1+
import { BaseBlockstore } from 'blockstore-core'
32
import merge from 'it-merge'
43
import pushable from 'it-pushable'
54
import filter from 'it-filter'
@@ -21,7 +20,7 @@ import filter from 'it-filter'
2120
*
2221
* @implements {Blockstore}
2322
*/
24-
export class BlockStorage extends BlockstoreAdapter {
23+
export class BlockStorage extends BaseBlockstore {
2524
/**
2625
* Create a new BlockStorage
2726
*

packages/ipfs-core/src/components/pin/add-all.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
import { resolvePath } from '../../utils.js'
44
import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option'
55
import { normaliseInput } from 'ipfs-core-utils/pins/normalise-input'
6-
import IpfsRepo from 'ipfs-repo'
7-
8-
const { PinTypes } = IpfsRepo
6+
import { PinTypes } from 'ipfs-repo/pin-types'
97

108
/**
119
* @typedef {import('ipfs-core-utils/src/pins/normalise-input').Source} Source

packages/ipfs-core/src/components/pin/ls.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import { normaliseInput } from 'ipfs-core-utils/pins/normalise-input'
44
import { resolvePath } from '../../utils.js'
55
import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option'
66
import errCode from 'err-code'
7-
import IpfsRepo from 'ipfs-repo'
8-
9-
const { PinTypes } = IpfsRepo
7+
import { PinTypes } from 'ipfs-repo/pin-types'
108

119
/**
1210
* @typedef {import('multiformats/cid').CID} CID

packages/ipfs-core/src/components/pin/rm-all.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { normaliseInput } from 'ipfs-core-utils/pins/normalise-input'
22
import { resolvePath } from '../../utils.js'
33
import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option'
4-
import IpfsRepo from 'ipfs-repo'
5-
6-
const { PinTypes } = IpfsRepo
4+
import { PinTypes } from 'ipfs-repo/pin-types'
75

86
/**
97
* @param {Object} config

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
21
import * as dagPB from '@ipld/dag-pb'
3-
import { Errors } from 'interface-datastore'
2+
import { notFoundError } from 'datastore-core/errors'
43
import { toCidAndPath } from 'ipfs-core-utils/to-cid-and-path'
54
import { CID } from 'multiformats/cid'
65
// @ts-expect-error no types
76
import TimeoutController from 'timeout-abort-controller'
87
import { anySignal } from 'any-signal'
98

10-
const ERR_NOT_FOUND = Errors.notFoundError().code
9+
const ERR_NOT_FOUND = notFoundError().code
1110

1211
export const Format = {
1312
default: '<dst>',

packages/ipfs-core/src/components/repo/version.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
21
import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option'
3-
import IpfsRepo from 'ipfs-repo'
4-
5-
const { repoVersion } = IpfsRepo
2+
import { repoVersion } from 'ipfs-repo/constants'
63

74
/**
85
* @param {Object} config

packages/ipfs-core/src/components/storage.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import debug from 'debug'
32
import { createRepo } from 'ipfs-core-config/repo'
43
import getDefaultConfig from 'ipfs-core-config/config'
@@ -9,9 +8,7 @@ import mergeOpts from 'merge-options'
98
import { profiles as configProfiles } from './config/profiles.js'
109
import { NotEnabledError, NotInitializedError } from '../errors.js'
1110
import { createLibp2p } from './libp2p.js'
12-
import IpfsRepo from 'ipfs-repo'
13-
14-
const { errors } = IpfsRepo
11+
import { ERR_REPO_NOT_INITIALIZED } from 'ipfs-repo/errors'
1512

1613
const mergeOptions = mergeOpts.bind({ ignoreUndefined: true })
1714
const log = debug('ipfs:components:peer:storage')
@@ -83,7 +80,7 @@ const loadRepo = async (print, repo, options) => {
8380

8481
return { ...await configureRepo(repo, options), isNew: false }
8582
} catch (/** @type {any} */ err) {
86-
if (err.code !== errors.ERR_REPO_NOT_INITIALIZED) {
83+
if (err.code !== ERR_REPO_NOT_INITIALIZED) {
8784
throw err
8885
}
8986

0 commit comments

Comments
 (0)