chore: Upgrade Helia.

This commit is contained in:
Hayden Young 2024-01-09 16:50:25 +00:00
parent b105dd489a
commit ba043391d9
6 changed files with 8288 additions and 896 deletions

9160
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -29,10 +29,12 @@
"uint8arrays": "^5.0.0" "uint8arrays": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"@chainsafe/libp2p-yamux": "^6.0.1",
"@libp2p/circuit-relay-v2": "^1.0.10",
"c8": "^8.0.1", "c8": "^8.0.1",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"fs-extra": "^11.2.0", "fs-extra": "^11.2.0",
"helia": "^2.1.0", "helia": "^3.0.0",
"it-all": "^3.0.4", "it-all": "^3.0.4",
"jsdoc": "^4.0.2", "jsdoc": "^4.0.2",
"mocha": "^10.2.0", "mocha": "^10.2.0",

View File

@ -1,11 +1,11 @@
import { identifyService } from 'libp2p/identify' import { identify } from '@libp2p/identify'
import { webSockets } from '@libp2p/websockets' import { webSockets } from '@libp2p/websockets'
import { webRTC } from '@libp2p/webrtc' import { webRTC } from '@libp2p/webrtc'
import { all } from '@libp2p/websockets/filters' import { all } from '@libp2p/websockets/filters'
import { noise } from '@chainsafe/libp2p-noise' import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux' import { yamux } from '@chainsafe/libp2p-yamux'
import { gossipsub } from '@chainsafe/libp2p-gossipsub' import { gossipsub } from '@chainsafe/libp2p-gossipsub'
import { circuitRelayTransport } from 'libp2p/circuit-relay' import { circuitRelayTransport } from '@libp2p/circuit-relay-v2'
/** /**
* A basic Libp2p configuration for Node.js nodes. * A basic Libp2p configuration for Node.js nodes.
@ -29,7 +29,7 @@ export const DefaultLibp2pOptions = {
denyDialMultiaddr: () => false denyDialMultiaddr: () => false
}, },
services: { services: {
identify: identifyService(), identify: identify(),
pubsub: gossipsub({ allowPublishToZeroPeers: true }) pubsub: gossipsub({ allowPublishToZeroPeers: true })
} }
} }
@ -56,7 +56,7 @@ export const DefaultLibp2pBrowserOptions = {
denyDialMultiaddr: () => false denyDialMultiaddr: () => false
}, },
services: { services: {
identify: identifyService(), identify: identify(),
pubsub: gossipsub({ allowPublishToZeroPeers: true }) pubsub: gossipsub({ allowPublishToZeroPeers: true })
} }
} }

View File

@ -141,7 +141,7 @@ const Sync = async ({ ipfs, log, events, onSynced, start, timeout }) => {
events.emit('join', peerId, heads) events.emit('join', peerId, heads)
} }
const sendHeads = async (source) => { const sendHeads = (source) => {
return (async function * () { return (async function * () {
const heads = await log.heads() const heads = await log.heads()
for await (const { bytes } of heads) { for await (const { bytes } of heads) {

View File

@ -697,7 +697,7 @@ describe('Sync protocol', function () {
await ipfs2.stop() await ipfs2.stop()
}) })
it('emits an error when connecting to peer was cancelled due to timeout', async () => { it.only('emits an error when connecting to peer was cancelled due to timeout', async () => {
let err = null let err = null
const onError = (error) => { const onError = (error) => {
@ -718,7 +718,7 @@ describe('Sync protocol', function () {
notStrictEqual(err, null) notStrictEqual(err, null)
strictEqual(err.type, 'aborted') strictEqual(err.type, 'aborted')
strictEqual(err.message, 'The operation was aborted') strictEqual(err.message, 'Read aborted')
}) })
}) })
}) })

View File

@ -1,10 +1,10 @@
import { yamux } from '@chainsafe/libp2p-yamux' import { yamux } from '@chainsafe/libp2p-yamux'
import { createLibp2p } from 'libp2p' import { createLibp2p } from 'libp2p'
import { noise } from '@chainsafe/libp2p-noise' import { noise } from '@chainsafe/libp2p-noise'
import { circuitRelayServer } from 'libp2p/circuit-relay' import { circuitRelayServer } from '@libp2p/circuit-relay-v2'
import { webSockets } from '@libp2p/websockets' import { webSockets } from '@libp2p/websockets'
import * as filters from '@libp2p/websockets/filters' import * as filters from '@libp2p/websockets/filters'
import { identifyService } from 'libp2p/identify' import { identify } from '@libp2p/identify'
import { createFromPrivKey } from '@libp2p/peer-id-factory' import { createFromPrivKey } from '@libp2p/peer-id-factory'
import { unmarshalPrivateKey } from '@libp2p/crypto/keys' import { unmarshalPrivateKey } from '@libp2p/crypto/keys'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
@ -31,7 +31,7 @@ const server = await createLibp2p({
connectionEncryption: [noise()], connectionEncryption: [noise()],
streamMuxers: [yamux()], streamMuxers: [yamux()],
services: { services: {
identify: identifyService(), identify: identify(),
relay: circuitRelayServer({ relay: circuitRelayServer({
reservations: { reservations: {
maxReservations: 5000, maxReservations: 5000,