dep: update helia and add delegatedPeerRouting back
This commit is contained in:
parent
d8899221d2
commit
1a544d7c2d
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
|
@ -31,7 +31,7 @@
|
|||
"blockstore-idb": "^1.1.1",
|
||||
"datastore-core": "^9.2.0",
|
||||
"datastore-idb": "^2.1.2",
|
||||
"helia": "1.3.5",
|
||||
"helia": "^2.0.3",
|
||||
"ipfs-http-client": "^60.0.1",
|
||||
"multiformats": "^12.0.1",
|
||||
"p-defer": "^4.0.0",
|
||||
|
@ -46,12 +46,12 @@
|
|||
"rollup-plugin-ignore-import": "^1.3.2"
|
||||
},
|
||||
"overrides": {
|
||||
"libp2p": "^0.45",
|
||||
"@libp2p/kad-dht": "^9.3.8",
|
||||
"libp2p": "^0.46.6",
|
||||
"@libp2p/kad-dht": "^10.0.2",
|
||||
"@chainsafe/libp2p-noise": "^12.0.0",
|
||||
"@libp2p/mplex": "^8.0.3",
|
||||
"@libp2p/bootstrap": "^8.0.0",
|
||||
"@chainsafe/libp2p-gossipsub": "^8.0.0",
|
||||
"@libp2p/mplex": "^9.0.2",
|
||||
"@libp2p/bootstrap": "^9.0.2",
|
||||
"@chainsafe/libp2p-gossipsub": "^10.0.0",
|
||||
"@libp2p/interface-datastore": "^8.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import type { BootstrapInit } from "@libp2p/bootstrap";
|
||||
|
||||
export const bootstrapConfig = {
|
||||
list: [
|
||||
"/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
|
||||
|
@ -54,4 +56,4 @@ export const bootstrapConfig = {
|
|||
"/ip6/2a01:4ff:f0:3764::1/tcp/4001/p2p/12D3KooWSDj6JM2JmoHwE9AUUwqAFUEg9ndd3pMA8aF2bkYckZfo",
|
||||
"/ip6/2a01:4ff:f0:3764::1/udp/4001/quic/p2p/12D3KooWSDj6JM2JmoHwE9AUUwqAFUEg9ndd3pMA8aF2bkYckZfo",
|
||||
],
|
||||
};
|
||||
} as BootstrapInit;
|
||||
|
|
|
@ -18,7 +18,14 @@ import { reframeContentRouting } from "@libp2p/reframe-content-routing";
|
|||
import { multiaddr } from "@multiformats/multiaddr";
|
||||
import { create as createIpfsHttpClient } from "ipfs-http-client";
|
||||
import { delegatedContentRouting } from "@libp2p/delegated-content-routing";
|
||||
import { delegatedPeerRouting } from "@libp2p/delegated-peer-routing";
|
||||
import { circuitRelayTransport } from "libp2p/circuit-relay";
|
||||
import { DELEGATE_LIST } from "./constants.js";
|
||||
import { webSockets } from "@libp2p/websockets";
|
||||
import { webTransport } from "@libp2p/webtransport";
|
||||
import { dcutrService } from "libp2p/dcutr";
|
||||
// @ts-ignore
|
||||
import type { DefaultLibp2pServices } from "helia/dist/src/utils/libp2p-defaults.browser.js";
|
||||
|
||||
function getDelegateConfig(): any {
|
||||
const delegateString =
|
||||
|
@ -34,19 +41,22 @@ function getDelegateConfig(): any {
|
|||
};
|
||||
}
|
||||
|
||||
export function libp2pConfig(proxy: MultiSocketProxy): Libp2pOptions<{
|
||||
dht: DualKadDHT;
|
||||
pubsub: PubSub;
|
||||
identify: unknown;
|
||||
autoNAT: unknown;
|
||||
}> {
|
||||
export function libp2pConfig(
|
||||
proxy: MultiSocketProxy,
|
||||
): Libp2pOptions<DefaultLibp2pServices> {
|
||||
const client = createIpfsHttpClient(getDelegateConfig());
|
||||
|
||||
return {
|
||||
addresses: {
|
||||
listen: [],
|
||||
},
|
||||
transports: [hypercoreTransport({ proxy })],
|
||||
transports: [
|
||||
circuitRelayTransport({
|
||||
discoverRelays: 1,
|
||||
}),
|
||||
webTransport(),
|
||||
webSockets(),
|
||||
],
|
||||
connectionEncryption: [noise()],
|
||||
streamMuxers: [yamux(), mplex()],
|
||||
peerDiscovery: [bootstrap(bootstrapConfig)],
|
||||
|
@ -55,10 +65,12 @@ export function libp2pConfig(proxy: MultiSocketProxy): Libp2pOptions<{
|
|||
ipniContentRouting("https://cid.contact"),
|
||||
reframeContentRouting("https://cid.contact/reframe"),
|
||||
],
|
||||
peerRouters: [delegatedPeerRouting(client)],
|
||||
services: {
|
||||
identify: identifyService(),
|
||||
autoNAT: autoNATService(),
|
||||
pubsub: gossipsub(),
|
||||
dcutr: dcutrService(),
|
||||
dht: kadDHT({
|
||||
clientMode: true,
|
||||
validators: {
|
||||
|
|
10
src/index.ts
10
src/index.ts
|
@ -1,6 +1,4 @@
|
|||
import { createHelia } from "helia";
|
||||
// @ts-ignore
|
||||
import Hyperswarm from "hyperswarm";
|
||||
import { MultiSocketProxy } from "@lumeweb/libhyperproxy";
|
||||
import { UnixFS, unixfs } from "@helia/unixfs";
|
||||
import { PROTOCOL } from "./constants.js";
|
||||
|
@ -11,9 +9,8 @@ import {
|
|||
} from "@lumeweb/libkernel/module";
|
||||
import { createClient } from "@lumeweb/kernel-swarm-client";
|
||||
import { ipns, IPNS } from "@helia/ipns";
|
||||
import { dht, pubsub } from "@helia/ipns/routing";
|
||||
import { dht } from "@helia/ipns/routing";
|
||||
// @ts-ignore
|
||||
import { gossipsub } from "@chainsafe/libp2p-gossipsub";
|
||||
import { CID } from "multiformats/cid";
|
||||
import { bases } from "multiformats/basics";
|
||||
import { substr } from "runes2";
|
||||
|
@ -27,6 +24,7 @@ import { Helia } from "@helia/interface";
|
|||
import type { Components } from "libp2p/src/components.js";
|
||||
import { libp2pConfig } from "./config.js";
|
||||
import { createClient as createNetworkRegistryClient } from "@lumeweb/kernel-network-registry-client";
|
||||
import { Libp2p } from "@libp2p/interface";
|
||||
|
||||
const basesByPrefix: { [prefix: string]: MultibaseDecoder<any> } = Object.keys(
|
||||
bases,
|
||||
|
@ -50,7 +48,7 @@ let swarm;
|
|||
let proxy: MultiSocketProxy;
|
||||
let fs: UnixFS;
|
||||
let IPNS: IPNS;
|
||||
let ipfs: Helia;
|
||||
let ipfs: Helia<Libp2p<any>>;
|
||||
|
||||
// @ts-ignore
|
||||
BigInt.prototype.toJSON = function () {
|
||||
|
@ -106,7 +104,7 @@ async function handlePresentKey() {
|
|||
await swarm.ready();
|
||||
// @ts-ignore
|
||||
fs = unixfs(ipfs);
|
||||
IPNS = ipns(ipfs as any, [dht(ipfs), pubsub(ipfs as any)]);
|
||||
IPNS = ipns(ipfs as any, [dht(ipfs)]);
|
||||
|
||||
ipfs.libp2p.addEventListener("peer:connect", () => {
|
||||
if (ipfs.libp2p.getPeers().length > 0) {
|
||||
|
|
Loading…
Reference in New Issue