Compare commits

..

4 Commits

Author SHA1 Message Date
semantic-release-bot c8f3cc70da chore(release): 0.1.0-develop.13 [skip ci]
# [0.1.0-develop.13](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.12...v0.1.0-develop.13) (2023-07-31)

### Bug Fixes

* add event listener on libp2p start for redundancy to ensure we max the events to read the peer count ([f1b8a60](f1b8a603df))
2023-07-31 01:34:41 +00:00
Derrick Hammer d23c583cf5
Merge remote-tracking branch 'origin/develop' into develop 2023-07-30 21:33:03 -04:00
Derrick Hammer f1b8a603df
fix: add event listener on libp2p start for redundancy to ensure we max the events to read the peer count 2023-07-30 21:32:53 -04:00
Derrick Hammer 2b04fecc7c
refactor: switch to ipni/reframe content routing and deprecate delegated routing 2023-07-30 21:32:04 -04:00
6 changed files with 62 additions and 45 deletions

View File

@ -1,3 +1,10 @@
# [0.1.0-develop.13](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.12...v0.1.0-develop.13) (2023-07-31)
### Bug Fixes
* add event listener on libp2p start for redundancy to ensure we max the events to read the peer count ([f1b8a60](https://git.lumeweb.com/LumeWeb/kernel-ipfs/commit/f1b8a603dfdca93e08692e7ad29fd2466c76d6d0))
# [0.1.0-develop.12](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.11...v0.1.0-develop.12) (2023-07-30) # [0.1.0-develop.12](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.11...v0.1.0-develop.12) (2023-07-30)
# [0.1.0-develop.11](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.10...v0.1.0-develop.11) (2023-07-29) # [0.1.0-develop.11](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.10...v0.1.0-develop.11) (2023-07-29)

62
npm-shrinkwrap.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@lumeweb/kernel-ipfs", "name": "@lumeweb/kernel-ipfs",
"version": "0.1.0-develop.12", "version": "0.1.0-develop.13",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@lumeweb/kernel-ipfs", "name": "@lumeweb/kernel-ipfs",
"version": "0.1.0-develop.12", "version": "0.1.0-develop.13",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@helia/ipns": "^1.1.3", "@helia/ipns": "^1.1.3",
@ -14,6 +14,7 @@
"@libp2p/delegated-content-routing": "^4.0.6", "@libp2p/delegated-content-routing": "^4.0.6",
"@libp2p/delegated-peer-routing": "^4.0.9", "@libp2p/delegated-peer-routing": "^4.0.9",
"@libp2p/peer-id": "^2.0.4", "@libp2p/peer-id": "^2.0.4",
"@libp2p/reframe-content-routing": "^1.0.1",
"@libp2p/tcp": "7.0.3", "@libp2p/tcp": "7.0.3",
"@lumeweb/kernel-network-registry-client": "^0.1.0-develop.5", "@lumeweb/kernel-network-registry-client": "^0.1.0-develop.5",
"@lumeweb/kernel-protomux-client": "^0.0.2-develop.15", "@lumeweb/kernel-protomux-client": "^0.0.2-develop.15",
@ -2928,6 +2929,39 @@
"npm": ">=7.0.0" "npm": ">=7.0.0"
} }
}, },
"node_modules/@libp2p/reframe-content-routing": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@libp2p/reframe-content-routing/-/reframe-content-routing-1.0.1.tgz",
"integrity": "sha512-Jcm5F4y9c2kfTLls6aYw5ejDfJ1RIgjW2VMcFcPCOHeCQetcnn7TS0zf7t6sqn8vMCPjVy6AYcn/NoyoF2g+1A==",
"dependencies": {
"@libp2p/interface-content-routing": "^2.0.2",
"@libp2p/interface-peer-info": "^1.0.9",
"@libp2p/interfaces": "^3.3.1",
"@libp2p/logger": "^2.0.7",
"@libp2p/peer-id": "^2.0.3",
"@multiformats/multiaddr": "^12.1.2",
"any-signal": "^4.1.1",
"browser-readablestream-to-it": "^2.0.2",
"it-to-buffer": "^4.0.1",
"multiformats": "^11.0.2",
"p-defer": "^4.0.0",
"p-queue": "^7.3.4",
"uint8arrays": "^4.0.3"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/@libp2p/reframe-content-routing/node_modules/multiformats": {
"version": "11.0.2",
"resolved": "https://registry.npmjs.org/multiformats/-/multiformats-11.0.2.tgz",
"integrity": "sha512-b5mYMkOkARIuVZCpvijFj9a6m5wMVLC7cf/jIPd5D/ARDOfLC5+IFkbgDXQgcU2goIsTD/O9NY4DI/Mt4OGvlg==",
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/@libp2p/tcp": { "node_modules/@libp2p/tcp": {
"version": "7.0.3", "version": "7.0.3",
"resolved": "https://registry.npmjs.org/@libp2p/tcp/-/tcp-7.0.3.tgz", "resolved": "https://registry.npmjs.org/@libp2p/tcp/-/tcp-7.0.3.tgz",
@ -3034,18 +3068,6 @@
"npm": ">=8.6.0" "npm": ">=8.6.0"
} }
}, },
"node_modules/@libp2p/webrtc/node_modules/it-to-buffer": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/it-to-buffer/-/it-to-buffer-4.0.2.tgz",
"integrity": "sha512-PCUk9Vn9E9qGYTvGuG9AFSzVflQHW4kRdo2X+c9mU+ZUXPt+szysqDFz46hswQmkYfPvP2xWK5C+q4RI21273g==",
"dependencies": {
"uint8arrays": "^4.0.2"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/@libp2p/webrtc/node_modules/multiformats": { "node_modules/@libp2p/webrtc/node_modules/multiformats": {
"version": "11.0.2", "version": "11.0.2",
"resolved": "https://registry.npmjs.org/multiformats/-/multiformats-11.0.2.tgz", "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-11.0.2.tgz",
@ -12196,6 +12218,18 @@
"npm": ">=7.0.0" "npm": ">=7.0.0"
} }
}, },
"node_modules/it-to-buffer": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/it-to-buffer/-/it-to-buffer-4.0.2.tgz",
"integrity": "sha512-PCUk9Vn9E9qGYTvGuG9AFSzVflQHW4kRdo2X+c9mU+ZUXPt+szysqDFz46hswQmkYfPvP2xWK5C+q4RI21273g==",
"dependencies": {
"uint8arrays": "^4.0.2"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/it-to-stream": { "node_modules/it-to-stream": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/it-to-stream/-/it-to-stream-1.0.0.tgz", "resolved": "https://registry.npmjs.org/it-to-stream/-/it-to-stream-1.0.0.tgz",

View File

@ -1,6 +1,6 @@
{ {
"name": "@lumeweb/kernel-ipfs", "name": "@lumeweb/kernel-ipfs",
"version": "0.1.0-develop.12", "version": "0.1.0-develop.13",
"type": "module", "type": "module",
"readme": "ERROR: No README data found!", "readme": "ERROR: No README data found!",
"repository": { "repository": {
@ -19,6 +19,7 @@
"@libp2p/delegated-content-routing": "^4.0.6", "@libp2p/delegated-content-routing": "^4.0.6",
"@libp2p/delegated-peer-routing": "^4.0.9", "@libp2p/delegated-peer-routing": "^4.0.9",
"@libp2p/peer-id": "^2.0.4", "@libp2p/peer-id": "^2.0.4",
"@libp2p/reframe-content-routing": "^1.0.1",
"@libp2p/tcp": "7.0.3", "@libp2p/tcp": "7.0.3",
"@lumeweb/kernel-network-registry-client": "^0.1.0-develop.5", "@lumeweb/kernel-network-registry-client": "^0.1.0-develop.5",
"@lumeweb/kernel-protomux-client": "^0.0.2-develop.15", "@lumeweb/kernel-protomux-client": "^0.0.2-develop.15",

View File

@ -13,26 +13,8 @@ import type { PubSub } from "@libp2p/interface-pubsub";
import type { Libp2pOptions } from "libp2p"; import type { Libp2pOptions } from "libp2p";
import { hypercoreTransport } from "./libp2p/transport.js"; import { hypercoreTransport } from "./libp2p/transport.js";
import { MultiSocketProxy } from "@lumeweb/libhyperproxy"; import { MultiSocketProxy } from "@lumeweb/libhyperproxy";
import { delegatedContentRouting } from "@libp2p/delegated-content-routing";
import { delegatedPeerRouting } from "@libp2p/delegated-peer-routing";
import { create as createIpfsHttpClient } from "ipfs-http-client";
import { DELEGATE_LIST } from "./constants.js";
import { multiaddr } from "@multiformats/multiaddr";
import { ipniContentRouting } from "@libp2p/ipni-content-routing"; import { ipniContentRouting } from "@libp2p/ipni-content-routing";
import { reframeContentRouting } from "@libp2p/reframe-content-routing";
function getDelegateConfig(): any {
const delegateString =
DELEGATE_LIST[Math.floor(Math.random() * DELEGATE_LIST.length)];
const delegateAddr = multiaddr(delegateString).toOptions();
return {
// @ts-ignore
host: delegateAddr.host,
// @ts-ignore
protocol: parseInt(delegateAddr.port) === 443 ? "https" : "http",
port: delegateAddr.port,
};
}
export function libp2pConfig(proxy: MultiSocketProxy): Libp2pOptions<{ export function libp2pConfig(proxy: MultiSocketProxy): Libp2pOptions<{
dht: DualKadDHT; dht: DualKadDHT;
@ -40,8 +22,6 @@ export function libp2pConfig(proxy: MultiSocketProxy): Libp2pOptions<{
identify: unknown; identify: unknown;
autoNAT: unknown; autoNAT: unknown;
}> { }> {
const client = createIpfsHttpClient(getDelegateConfig());
return { return {
addresses: { addresses: {
listen: [], listen: [],
@ -51,10 +31,9 @@ export function libp2pConfig(proxy: MultiSocketProxy): Libp2pOptions<{
streamMuxers: [yamux(), mplex()], streamMuxers: [yamux(), mplex()],
peerDiscovery: [bootstrap(bootstrapConfig)], peerDiscovery: [bootstrap(bootstrapConfig)],
contentRouters: [ contentRouters: [
delegatedContentRouting(client),
ipniContentRouting("https://cid.contact"), ipniContentRouting("https://cid.contact"),
reframeContentRouting("https://cid.contact/reframe"),
], ],
peerRouters: [delegatedPeerRouting(client)],
services: { services: {
identify: identifyService(), identify: identifyService(),
autoNAT: autoNATService(), autoNAT: autoNATService(),

View File

@ -1,8 +1 @@
export const PROTOCOL = "lumeweb.proxy.ipfs"; export const PROTOCOL = "lumeweb.proxy.ipfs";
export const DELEGATE_LIST = [
"/dns4/node0.delegate.ipfs.io/tcp/443/https",
"/dns4/node1.delegate.ipfs.io/tcp/443/https",
"/dns4/node2.delegate.ipfs.io/tcp/443/https",
"/dns4/node3.delegate.ipfs.io/tcp/443/https",
];

View File

@ -339,6 +339,8 @@ async function handleStatus(aq: ActiveQuery) {
peersListener, peersListener,
); );
ipfs.libp2p.addEventListener("start", peersListener);
aq.setReceiveUpdate?.(() => { aq.setReceiveUpdate?.(() => {
peerEvents.forEach((ev) => { peerEvents.forEach((ev) => {
// @ts-ignore // @ts-ignore
@ -347,6 +349,7 @@ async function handleStatus(aq: ActiveQuery) {
peersListener, peersListener,
); );
}); });
ipfs.libp2p.removeEventListener("start", peersListener);
aq.respond(); aq.respond();
}); });