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

Commit

Permalink
chore: update datastore implemenations
Browse files Browse the repository at this point in the history
Pulls in esm versions of datastore/blockstore.

Also ipfs-repo, bitswap, ipns, etc.
  • Loading branch information
achingbrain committed Sep 24, 2021
1 parent be4a542 commit 3641403
Show file tree
Hide file tree
Showing 35 changed files with 103 additions and 105 deletions.
3 changes: 2 additions & 1 deletion packages/interface-ipfs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"@types/readable-stream": "^2.3.11",
"abort-controller": "^3.0.0",
"aegir": "^35.1.0",
"blockstore-core": "^1.0.2",
"copyfiles": "^2.4.1",
"delay": "^5.0.0",
"err-code": "^3.0.1",
Expand All @@ -76,7 +77,7 @@
"ipfs-unixfs": "^6.0.3",
"ipfs-unixfs-importer": "^9.0.3",
"ipfs-utils": "^9.0.1",
"ipns": "^0.14.0",
"ipns": "^0.15.0",
"is-ipfs": "^6.0.1",
"iso-random-stream": "^2.0.0",
"it-all": "^1.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/interface-ipfs-core/src/name-pubsub/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { expect } from 'aegir/utils/chai.js'
import { getDescribe, getIt } from '../utils/mocha.js'
import PeerId from 'peer-id'
import { isNode } from 'ipfs-utils/src/env.js'
import ipns from 'ipns'
import * as ipns from 'ipns'
import delay from 'delay'
import last from 'it-last'
import waitFor from '../utils/wait-for.js'
Expand Down
4 changes: 2 additions & 2 deletions packages/interface-ipfs-core/src/utils/blockstore-adapter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BlockstoreAdapter } from 'interface-blockstore'
import { BaseBlockstore } from 'blockstore-core/base'
import * as raw from 'multiformats/codecs/raw'
import * as dagPB from '@ipld/dag-pb'
import * as dagCBOR from '@ipld/dag-cbor'
Expand All @@ -21,7 +21,7 @@ const hashes = {
[sha256.code]: sha256.name
}

class IPFSBlockstore extends BlockstoreAdapter {
class IPFSBlockstore extends BaseBlockstore {
/**
* @param {import('ipfs-core-types').IPFS} ipfs
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/ipfs-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@
"ipfs-core-utils": "^0.10.5",
"ipfs-daemon": "^0.9.8",
"ipfs-http-client": "^52.0.5",
"ipfs-repo": "^12.0.0",
"ipfs-repo": "^13.0.4",
"ipfs-utils": "^9.0.1",
"it-all": "^1.0.4",
"it-concat": "^2.0.0",
"it-first": "^1.0.4",
"it-glob": "1.0.0",
"it-glob": "^1.0.0",
"it-map": "^1.0.5",
"it-merge": "^1.0.3",
"it-pipe": "^1.1.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/ipfs-core-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@
"license": "MIT",
"dependencies": {
"@chainsafe/libp2p-noise": "^4.0.0",
"blockstore-datastore-adapter": "^1.0.2",
"datastore-core": "^5.0.1",
"datastore-fs": "^5.0.2",
"datastore-level": "^6.0.2",
"blockstore-datastore-adapter": "^2.0.2",
"datastore-core": "^6.0.7",
"datastore-fs": "^6.0.1",
"datastore-level": "^7.0.1",
"debug": "^4.1.1",
"err-code": "^3.0.1",
"hashlru": "^2.3.0",
"ipfs-repo": "^12.0.0",
"ipfs-repo": "^13.0.4",
"ipfs-utils": "^9.0.1",
"ipns": "^0.14.0",
"ipns": "^0.15.0",
"is-ipfs": "^6.0.1",
"it-all": "^1.0.4",
"it-drain": "^1.0.3",
Expand Down
19 changes: 10 additions & 9 deletions packages/ipfs-core-config/src/repo.browser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import { createRepo as create } from 'ipfs-repo'
import DatastoreLevel from 'datastore-level'
import BlockstoreDatastoreAdapter from 'blockstore-datastore-adapter'
import { LevelDatastore } from 'datastore-level'
import { BlockstoreDatastoreAdapter } from 'blockstore-datastore-adapter'
import { MemoryLock } from 'ipfs-repo/locks/memory'

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

return create(repoPath, (codeOrName) => codecs.getCodec(codeOrName), {
root: new DatastoreLevel(repoPath, {
root: new LevelDatastore(repoPath, {
prefix: '',
version: 2
}),
blocks: new BlockstoreDatastoreAdapter(
new DatastoreLevel(`${repoPath}/blocks`, {
new LevelDatastore(`${repoPath}/blocks`, {
prefix: '',
version: 2
})
),
datastore: new DatastoreLevel(`${repoPath}/datastore`, {
datastore: new LevelDatastore(`${repoPath}/datastore`, {
prefix: '',
version: 2
}),
keys: new DatastoreLevel(`${repoPath}/keys`, {
keys: new LevelDatastore(`${repoPath}/keys`, {
prefix: '',
version: 2
}),
pins: new DatastoreLevel(`${repoPath}/pins`, {
pins: new LevelDatastore(`${repoPath}/pins`, {
prefix: '',
version: 2
})
}, {
autoMigrate: options.autoMigrate,
onMigrationProgress: options.onMigrationProgress || print
onMigrationProgress: options.onMigrationProgress || print,
repoLock: MemoryLock
})
}
25 changes: 13 additions & 12 deletions packages/ipfs-core-config/src/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import os from 'os'
import { createRepo as create } from 'ipfs-repo'
import path from 'path'
import DatastoreFS from 'datastore-fs'
import DatastoreLevel from 'datastore-level'
import BlockstoreDatastoreAdapter from 'blockstore-datastore-adapter'
import { ShardingDatastore, shard } from 'datastore-core'

const { NextToLast } = shard
import { FsDatastore } from 'datastore-fs'
import { LevelDatastore } from 'datastore-level'
import { BlockstoreDatastoreAdapter } from 'blockstore-datastore-adapter'
import { ShardingDatastore } from 'datastore-core/sharding'
import { NextToLast } from 'datastore-core/shard'
import { FSLock } from 'ipfs-repo/locks/fs'

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

return create(repoPath, (codeOrName) => codecs.getCodec(codeOrName), {
root: new DatastoreFS(repoPath, {
root: new FsDatastore(repoPath, {
extension: ''
}),
blocks: new BlockstoreDatastoreAdapter(
new ShardingDatastore(
new DatastoreFS(`${repoPath}/blocks`, {
new FsDatastore(`${repoPath}/blocks`, {
extension: '.data'
}),
new NextToLast(2)
)
),
datastore: new DatastoreLevel(`${repoPath}/datastore`),
keys: new DatastoreFS(`${repoPath}/keys`),
pins: new DatastoreLevel(`${repoPath}/pins`)
datastore: new LevelDatastore(`${repoPath}/datastore`),
keys: new FsDatastore(`${repoPath}/keys`),
pins: new LevelDatastore(`${repoPath}/pins`)
}, {
autoMigrate: options.autoMigrate != null ? options.autoMigrate : true,
onMigrationProgress: onMigrationProgress
onMigrationProgress: onMigrationProgress,
repoLock: FSLock
})
}
3 changes: 1 addition & 2 deletions packages/ipfs-core-config/src/utils/ipns.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

import ipns from 'ipns'
import * as ipns from 'ipns'

export const validator = {
/**
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 @@ -44,7 +44,7 @@
],
"license": "(Apache-2.0 OR MIT)",
"dependencies": {
"interface-datastore": "^5.2.0",
"interface-datastore": "^6.0.2",
"multiaddr": "^10.0.0",
"multiformats": "^9.4.1"
},
Expand Down
1 change: 1 addition & 0 deletions packages/ipfs-core-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
"any-signal": "^2.1.2",
"blob-to-it": "^1.0.1",
"browser-readablestream-to-it": "^1.0.1",
"debug": "^4.1.1",
"err-code": "^3.0.1",
"ipfs-core-types": "^0.7.3",
"ipfs-unixfs": "^6.0.3",
Expand Down
5 changes: 4 additions & 1 deletion packages/ipfs-core-utils/src/multipart-request.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { modeToString } from './mode-to-string.js'
import mergeOpts from 'merge-options'
// @ts-expect-error no types
import toStream from 'it-to-stream'
import debug from 'debug'

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

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

index++
}
} catch {
} catch (err) {
log(err)
// workaround for https://github.com/node-fetch/node-fetch/issues/753
abortController.abort()
} finally {
Expand Down
31 changes: 18 additions & 13 deletions packages/ipfs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"test:electron-renderer": "aegir build --esm-tests && aegir test -t electron-renderer -f ./dist/cjs/browser-test/*.spec.js",
"test:bootstrapers": "IPFS_TEST=bootstrapers aegir test -t browser -f test/bootstrapers.js",
"clean": "rimraf ./dist",
"dep-check": "aegir dep-check -i interface-ipfs-core -i ipfs-core-types -i abort-controller -i npm-run-all"
"dep-check": "aegir dep-check -i interface-ipfs-core -i ipfs-core-types -i abort-controller -i npm-run-all --i interface-blockstore"
},
"dependencies": {
"@chainsafe/libp2p-noise": "^4.0.0",
Expand All @@ -72,27 +72,29 @@
"@multiformats/murmur3": "^1.0.1",
"any-signal": "^2.1.2",
"array-shuffle": "^2.0.0",
"blockstore-datastore-adapter": "^1.0.2",
"datastore-core": "^5.0.1",
"datastore-pubsub": "^0.7.0",
"blockstore-core": "^1.0.2",
"blockstore-datastore-adapter": "^2.0.2",
"datastore-core": "^6.0.7",
"datastore-fs": "^6.0.1",
"datastore-level": "^7.0.1",
"datastore-pubsub": "^1.0.0",
"debug": "^4.1.1",
"dlv": "^1.1.3",
"err-code": "^3.0.1",
"hamt-sharding": "^2.0.0",
"hashlru": "^2.3.0",
"interface-blockstore": "^1.0.0",
"interface-datastore": "^5.2.0",
"ipfs-bitswap": "^6.0.0",
"ipfs-core-config": "^0.0.1",
"interface-blockstore": "^2.0.2",
"interface-datastore": "^6.0.2",
"ipfs-bitswap": "^7.0.0",
"ipfs-core-types": "^0.7.3",
"ipfs-core-utils": "^0.10.5",
"ipfs-http-client": "^52.0.5",
"ipfs-repo": "^12.0.0",
"ipfs-repo": "^13.0.4",
"ipfs-unixfs": "^6.0.3",
"ipfs-unixfs-exporter": "^7.0.3",
"ipfs-unixfs-importer": "^9.0.3",
"ipfs-utils": "^9.0.1",
"ipns": "^0.14.0",
"ipfs-utils": "^8.1.4",
"ipns": "^0.15.0",
"is-domain-name": "^1.0.1",
"is-ipfs": "^6.0.1",
"it-all": "^1.0.4",
Expand All @@ -109,12 +111,15 @@
"it-tar": "^4.0.0",
"it-to-buffer": "^2.0.0",
"just-safe-set": "^2.2.1",
"libp2p": "^0.32.0",
"libp2p": "^0.33.0",
"libp2p-bootstrap": "^0.13.0",
"libp2p-crypto": "^0.19.7",
"libp2p-delegated-content-routing": "^0.11.0",
"libp2p-delegated-peer-routing": "^0.10.0",
"libp2p-gossipsub": "^0.11.1",
"libp2p-kad-dht": "^0.25.0",
"libp2p-mdns": "^0.17.0",
"libp2p-mplex": "^0.10.2",
"libp2p-record": "^0.10.3",
"mafmt": "^10.0.0",
"merge-options": "^3.0.4",
Expand All @@ -136,7 +141,7 @@
"aegir": "^35.1.0",
"delay": "^5.0.0",
"go-ipfs": "0.9.1",
"interface-blockstore-tests": "^1.0.0",
"interface-blockstore-tests": "^2.0.1",
"interface-ipfs-core": "^0.150.4",
"ipfsd-ctl": "^10.0.3",
"iso-url": "^1.0.0",
Expand Down
5 changes: 2 additions & 3 deletions packages/ipfs-core/src/block-storage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

import { BlockstoreAdapter } from 'interface-blockstore'
import { BaseBlockstore } from 'blockstore-core'
import merge from 'it-merge'
import pushable from 'it-pushable'
import filter from 'it-filter'
Expand All @@ -21,7 +20,7 @@ import filter from 'it-filter'
*
* @implements {Blockstore}
*/
export class BlockStorage extends BlockstoreAdapter {
export class BlockStorage extends BaseBlockstore {
/**
* Create a new BlockStorage
*
Expand Down
4 changes: 1 addition & 3 deletions packages/ipfs-core/src/components/pin/add-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import { resolvePath } from '../../utils.js'
import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option'
import { normaliseInput } from 'ipfs-core-utils/pins/normalise-input'
import IpfsRepo from 'ipfs-repo'

const { PinTypes } = IpfsRepo
import { PinTypes } from 'ipfs-repo/pin-types'

/**
* @typedef {import('ipfs-core-utils/src/pins/normalise-input').Source} Source
Expand Down
4 changes: 1 addition & 3 deletions packages/ipfs-core/src/components/pin/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { normaliseInput } from 'ipfs-core-utils/pins/normalise-input'
import { resolvePath } from '../../utils.js'
import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option'
import errCode from 'err-code'
import IpfsRepo from 'ipfs-repo'

const { PinTypes } = IpfsRepo
import { PinTypes } from 'ipfs-repo/pin-types'

/**
* @typedef {import('multiformats/cid').CID} CID
Expand Down
4 changes: 1 addition & 3 deletions packages/ipfs-core/src/components/pin/rm-all.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { normaliseInput } from 'ipfs-core-utils/pins/normalise-input'
import { resolvePath } from '../../utils.js'
import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option'
import IpfsRepo from 'ipfs-repo'

const { PinTypes } = IpfsRepo
import { PinTypes } from 'ipfs-repo/pin-types'

/**
* @param {Object} config
Expand Down
5 changes: 2 additions & 3 deletions packages/ipfs-core/src/components/refs/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

import * as dagPB from '@ipld/dag-pb'
import { Errors } from 'interface-datastore'
import { notFoundError } from 'datastore-core/errors'
import { toCidAndPath } from 'ipfs-core-utils/to-cid-and-path'
import { CID } from 'multiformats/cid'
// @ts-expect-error no types
import TimeoutController from 'timeout-abort-controller'
import { anySignal } from 'any-signal'

const ERR_NOT_FOUND = Errors.notFoundError().code
const ERR_NOT_FOUND = notFoundError().code

export const Format = {
default: '<dst>',
Expand Down
5 changes: 1 addition & 4 deletions packages/ipfs-core/src/components/repo/version.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option'
import IpfsRepo from 'ipfs-repo'

const { repoVersion } = IpfsRepo
import { repoVersion } from 'ipfs-repo/constants'

/**
* @param {Object} config
Expand Down
7 changes: 2 additions & 5 deletions packages/ipfs-core/src/components/storage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import debug from 'debug'
import { createRepo } from 'ipfs-core-config/repo'
import getDefaultConfig from 'ipfs-core-config/config'
Expand All @@ -9,9 +8,7 @@ import mergeOpts from 'merge-options'
import { profiles as configProfiles } from './config/profiles.js'
import { NotEnabledError, NotInitializedError } from '../errors.js'
import { createLibp2p } from './libp2p.js'
import IpfsRepo from 'ipfs-repo'

const { errors } = IpfsRepo
import { ERR_REPO_NOT_INITIALIZED } from 'ipfs-repo/errors'

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

return { ...await configureRepo(repo, options), isNew: false }
} catch (/** @type {any} */ err) {
if (err.code !== errors.ERR_REPO_NOT_INITIALIZED) {
if (err.code !== ERR_REPO_NOT_INITIALIZED) {
throw err
}

Expand Down
Loading

0 comments on commit 3641403

Please sign in to comment.