Skip to content

Commit

Permalink
Merge branch 'main' into bench/gc-update
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain authored Dec 30, 2023
2 parents 84d7a2b + 9efe50d commit f665e47
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 23 deletions.
8 changes: 4 additions & 4 deletions packages/helia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"@libp2p/dcutr": "^1.0.1",
"@libp2p/identify": "^1.0.1",
"@libp2p/interface": "^1.0.1",
"@libp2p/kad-dht": "^11.0.2",
"@libp2p/kad-dht": "^12.0.1",
"@libp2p/keychain": "^4.0.2",
"@libp2p/mdns": "^10.0.2",
"@libp2p/mplex": "^10.0.2",
Expand All @@ -110,16 +110,16 @@
"interface-datastore": "^8.0.0",
"interface-store": "^5.0.1",
"ipfs-bitswap": "^20.0.0",
"ipns": "^7.0.1",
"ipns": "^8.0.0",
"it-all": "^3.0.2",
"it-drain": "^3.0.1",
"it-filter": "^3.0.1",
"it-foreach": "^2.0.2",
"libp2p": "^1.0.3",
"mortice": "^3.0.1",
"multiformats": "^12.0.1",
"multiformats": "^13.0.0",
"p-defer": "^4.0.0",
"p-queue": "^7.3.4",
"p-queue": "^8.0.1",
"progress-events": "^1.0.0",
"uint8arrays": "^5.0.0"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/helia/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ export async function createHelia (init: HeliaInit = {}): Promise<Helia<unknown>
const datastore = init.datastore ?? new MemoryDatastore()
const blockstore = init.blockstore ?? new MemoryBlockstore()

let libp2p: Libp2p
let libp2p: Libp2p<DefaultLibp2pServices>

if (isLibp2p(init.libp2p)) {
libp2p = init.libp2p
libp2p = init.libp2p as any
} else {
libp2p = await createLibp2p({
libp2p = await createLibp2p<DefaultLibp2pServices>({
...init,
libp2p: init.libp2p,
datastore
Expand Down
4 changes: 2 additions & 2 deletions packages/helia/src/utils/libp2p-defaults.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { bootstrap } from '@libp2p/bootstrap'
import { circuitRelayTransport } from '@libp2p/circuit-relay-v2'
import { dcutr } from '@libp2p/dcutr'
import { type Identify, identify } from '@libp2p/identify'
import { type DualKadDHT, kadDHT } from '@libp2p/kad-dht'
import { type KadDHT, kadDHT } from '@libp2p/kad-dht'
import { keychain, type Keychain } from '@libp2p/keychain'
import { mplex } from '@libp2p/mplex'
import { ping, type PingService } from '@libp2p/ping'
Expand All @@ -27,7 +27,7 @@ export interface DefaultLibp2pServices extends Record<string, unknown> {
autoNAT: unknown
dcutr: unknown
delegatedRouting: unknown
dht: DualKadDHT
dht: KadDHT
identify: Identify
keychain: Keychain
ping: PingService
Expand Down
4 changes: 2 additions & 2 deletions packages/helia/src/utils/libp2p-defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { bootstrap } from '@libp2p/bootstrap'
import { circuitRelayTransport, circuitRelayServer, type CircuitRelayService } from '@libp2p/circuit-relay-v2'
import { dcutr } from '@libp2p/dcutr'
import { type Identify, identify } from '@libp2p/identify'
import { type DualKadDHT, kadDHT } from '@libp2p/kad-dht'
import { type KadDHT, kadDHT } from '@libp2p/kad-dht'
import { keychain, type Keychain } from '@libp2p/keychain'
import { mdns } from '@libp2p/mdns'
import { mplex } from '@libp2p/mplex'
Expand All @@ -29,7 +29,7 @@ export interface DefaultLibp2pServices extends Record<string, unknown> {
autoNAT: unknown
dcutr: unknown
delegatedRouting: unknown
dht: DualKadDHT
dht: KadDHT
identify: Identify
keychain: Keychain
ping: PingService
Expand Down
2 changes: 1 addition & 1 deletion packages/interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"interface-datastore": "^8.0.0",
"interface-store": "^5.0.1",
"ipfs-bitswap": "^20.0.0",
"multiformats": "^12.0.1",
"multiformats": "^13.0.0",
"progress-events": "^1.0.0"
},
"devDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions packages/interop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@chainsafe/libp2p-yamux": "^6.0.1",
"@helia/interface": "^2.1.0",
"@libp2p/identify": "^1.0.1",
"@libp2p/peer-id": "^4.0.3",
"@libp2p/tcp": "^9.0.1",
"@libp2p/websockets": "^8.0.1",
"@multiformats/sha3": "^3.0.0",
Expand All @@ -67,10 +68,10 @@
"ipfsd-ctl": "^13.0.0",
"it-all": "^3.0.2",
"it-to-buffer": "^4.0.1",
"kubo": "^0.24.0",
"kubo": "^0.25.0",
"kubo-rpc-client": "^3.0.1",
"libp2p": "^1.0.1",
"multiformats": "^12.0.1"
"multiformats": "^13.0.0"
},
"browser": {
"./dist/test/fixtures/create-helia.js": "./dist/test/fixtures/create-helia.browser.js",
Expand Down
7 changes: 4 additions & 3 deletions packages/interop/test/blockstore.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-env mocha */

import { peerIdFromString } from '@libp2p/peer-id'
import { expect } from 'aegir/chai'
import toBuffer from 'it-to-buffer'
import { CID } from 'multiformats/cid'
Expand All @@ -19,10 +20,10 @@ describe('blockstore', () => {
kubo = await createKuboNode()

// connect the two nodes
await helia.libp2p.peerStore.merge(kubo.peer.id, {
await helia.libp2p.peerStore.merge(peerIdFromString(kubo.peer.id.toString()), {
multiaddrs: kubo.peer.addresses
})
await helia.libp2p.dial(kubo.peer.id)
await helia.libp2p.dial(peerIdFromString(kubo.peer.id.toString()))
})

afterEach(async () => {
Expand Down Expand Up @@ -51,7 +52,7 @@ describe('blockstore', () => {
cidVersion: 1,
rawLeaves: true
})
const output = await helia.blockstore.get(cid)
const output = await helia.blockstore.get(CID.parse(cid.toString()))

expect(output).to.equalBytes(input)
})
Expand Down
7 changes: 4 additions & 3 deletions packages/interop/test/hashes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-env mocha */

import { peerIdFromString } from '@libp2p/peer-id'
import { sha3512 } from '@multiformats/sha3'
import { expect } from 'aegir/chai'
import toBuffer from 'it-to-buffer'
Expand All @@ -23,10 +24,10 @@ describe('hashes', () => {
kubo = await createKuboNode()

// connect the two nodes
await helia.libp2p.peerStore.merge(kubo.peer.id, {
await helia.libp2p.peerStore.merge(peerIdFromString(kubo.peer.id.toString()), {
multiaddrs: kubo.peer.addresses
})
await helia.libp2p.dial(kubo.peer.id)
await helia.libp2p.dial(peerIdFromString(kubo.peer.id.toString()))
})

afterEach(async () => {
Expand Down Expand Up @@ -57,7 +58,7 @@ describe('hashes', () => {
hashAlg: 'sha3-512'
})
expect(cid.multihash.code).to.equal(sha3512.code)
const output = await helia.blockstore.get(cid)
const output = await helia.blockstore.get(CID.parse(cid.toString()))

expect(output).to.equalBytes(input)
})
Expand Down
6 changes: 3 additions & 3 deletions packages/interop/test/pins.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ describe('pins', () => {
rawLeaves: true
})

await expect(helia.blockstore.has(cid)).to.eventually.be.false()
await expect(helia.blockstore.has(CID.parse(cid.toString()))).to.eventually.be.false()

const output = await helia.pins.add(cid)
const output = await helia.pins.add(CID.parse(cid.toString()))

await expect(helia.blockstore.has(cid)).to.eventually.be.true()
await expect(helia.blockstore.has(CID.parse(cid.toString()))).to.eventually.be.true()

expect(output.cid.toString()).to.equal(cid.toString())
})
Expand Down

0 comments on commit f665e47

Please sign in to comment.