Skip to content

Commit

Permalink
Improve ConnectionStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
undyingwraith committed May 11, 2024
1 parent dfc42ce commit c0f57f5
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 125 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/components/molecules/ConnectionStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ export function ConnectionStatus(props: { ipfs: IIpfsService; }) {
horizontal: 'right',
}}
>
<List>
<List sx={{ width: '25vw' }}>
{peers.value.length > 0 ? peers.value.map(p => (
<ListItem key={p}>
<ListItemIcon>
<Identicon value={p} />
<Identicon value={p.substring(p.lastIndexOf('/'))} />
</ListItemIcon>
<ListItemText>{p}</ListItemText>
<ListItemText sx={{ textOverflow: 'ellipsis' }}>{p}</ListItemText>
</ListItem>
)) : (
<ListItem>
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/createRemoteIpfsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function createRemoteIpfsService(url: string): Promise<IIpfsService
},
async resolve(name) {
let result = '';
for await (const res of node.name.resolve(name)) {
for await (const res of node.name.resolve(name.at(0) == '/' ? name : '/ipns/' + name)) {
result = res;
}

Expand Down
3 changes: 0 additions & 3 deletions packages/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,12 @@
]
},
"dependencies": {
"@chainsafe/libp2p-gossipsub": "13.0.0",
"@chainsafe/libp2p-noise": "^15.0.0",
"@electron-toolkit/preload": "^3.0.1",
"@electron-toolkit/utils": "^3.0.0",
"@helia/unixfs": "^3.0.6",
"@libp2p/bootstrap": "^10.0.22",
"@libp2p/identify": "^2.0.0",
"@libp2p/pnet": "^1.0.1",
"@libp2p/pubsub-peer-discovery": "^10.0.2",
"@libp2p/tcp": "^9.0.16",
"@libp2p/websockets": "^8.0.16",
"@libp2p/webtransport": "4.0.21",
Expand Down
34 changes: 26 additions & 8 deletions packages/desktop/src/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import { createHelia } from 'helia';
import { IncomingMessage, Server, ServerResponse } from 'http';
import { IConfigurationService, IFileInfo, IInternalProfile, IIpfsService, INodeService, IProfile, createRemoteIpfsService } from 'ipmc-core';
import { CID } from 'multiformats';
//import { gossipsub } from '@chainsafe/libp2p-gossipsub';
//import { pubsubPeerDiscovery } from '@libp2p/pubsub-peer-discovery';
//import { identify } from '@libp2p/identify';
import { libp2pRouting } from '@helia/routers';

function getProfileFolder(name: string): string {
return `./profiles/${name}`;
Expand Down Expand Up @@ -66,14 +64,13 @@ const nodeService: INodeService = {
],
peerDiscovery: [
bootstrap({
list: profile.bootstrap ?? [
list: profile.bootstrap ?? (profile.swarmKey != undefined ? [] : [
// a list of bootstrap peer multiaddrs to connect to on node startup
'/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ',
'/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN',
'/dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa',
],
]),
}),
//pubsubPeerDiscovery(),
],
connectionEncryption: [
noise(),
Expand All @@ -83,15 +80,36 @@ const nodeService: INodeService = {
mplex(),
],
services: {
//identify: identify(),
relay: circuitRelayServer(),
//pubsub: gossipsub(),
dht: kadDHT({
protocol: '/ipfs/kad/1.0.0',
peerInfoMapper: removePrivateAddressesMapper
})
},
},
routers: [
{
findPeer(peerId, options) {
return libp2pRouting(helia.libp2p).findPeer(peerId, options);
},
findProviders(cid, options) {
return libp2pRouting(helia.libp2p).findProviders(cid, options);
},
get(key, options) {
return libp2pRouting(helia.libp2p).get(key, options);
},
getClosestPeers(key, options) {
return libp2pRouting(helia.libp2p).getClosestPeers(key, options);
},
provide(cid, options) {
return libp2pRouting(helia.libp2p).provide(cid, options);
},
put(key, value, options) {
return libp2pRouting(helia.libp2p).put(key, value, options);
},
}
,
],
blockBrokers: [
bitswap(),
...(profile.swarmKey == undefined ? [trustlessGateway()] : [])
Expand Down
152 changes: 42 additions & 110 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -501,28 +501,6 @@ __metadata:
languageName: node
linkType: hard

"@chainsafe/libp2p-gossipsub@npm:13.0.0":
version: 13.0.0
resolution: "@chainsafe/libp2p-gossipsub@npm:13.0.0"
dependencies:
"@libp2p/crypto": "npm:^4.0.1"
"@libp2p/interface": "npm:^1.1.2"
"@libp2p/interface-internal": "npm:^1.0.7"
"@libp2p/peer-id": "npm:^4.0.5"
"@libp2p/pubsub": "npm:^9.0.8"
"@multiformats/multiaddr": "npm:^12.1.14"
denque: "npm:^2.1.0"
it-length-prefixed: "npm:^9.0.4"
it-pipe: "npm:^3.0.1"
it-pushable: "npm:^3.2.3"
multiformats: "npm:^13.0.1"
protons-runtime: "npm:5.4.0"
uint8arraylist: "npm:^2.4.8"
uint8arrays: "npm:^5.0.1"
checksum: 10c0/bd60ef11d21835d63a2166f18168348b981a847b4895031a9539d373ed2e4d29597c6b203559c6d156849e028ffa42033b22befa1e44a49c65cf0df76ed72a64
languageName: node
linkType: hard

"@chainsafe/libp2p-noise@npm:^15.0.0":
version: 15.0.0
resolution: "@chainsafe/libp2p-noise@npm:15.0.0"
Expand Down Expand Up @@ -1734,35 +1712,35 @@ __metadata:
languageName: node
linkType: hard

"@libp2p/crypto@npm:^4.0.1, @libp2p/crypto@npm:^4.1.1":
version: 4.1.1
resolution: "@libp2p/crypto@npm:4.1.1"
"@libp2p/crypto@npm:^4.0.6":
version: 4.0.6
resolution: "@libp2p/crypto@npm:4.0.6"
dependencies:
"@libp2p/interface": "npm:^1.3.1"
"@libp2p/interface": "npm:^1.2.0"
"@noble/curves": "npm:^1.4.0"
"@noble/hashes": "npm:^1.4.0"
asn1js: "npm:^3.0.5"
multiformats: "npm:^13.1.0"
protons-runtime: "npm:^5.4.0"
uint8arraylist: "npm:^2.4.8"
uint8arrays: "npm:^5.0.3"
checksum: 10c0/b3bda92ce19c97b7e0993224d066c21d4f22556b0af725b6e5ba36998e5f1c4494010ac909d292aedb843b215edc86117b89a2f35a7ed65822164cd0829c3f20
checksum: 10c0/17dc384be739cb0a22d46e059d0fb154ee3e99fb119319397805d7d29988cce45b4d8c7874a8e46b7d3a7c265e6ca9bd8fd26aad21196fa1741c6766ca307ae6
languageName: node
linkType: hard

"@libp2p/crypto@npm:^4.0.6":
version: 4.0.6
resolution: "@libp2p/crypto@npm:4.0.6"
"@libp2p/crypto@npm:^4.1.1":
version: 4.1.1
resolution: "@libp2p/crypto@npm:4.1.1"
dependencies:
"@libp2p/interface": "npm:^1.2.0"
"@libp2p/interface": "npm:^1.3.1"
"@noble/curves": "npm:^1.4.0"
"@noble/hashes": "npm:^1.4.0"
asn1js: "npm:^3.0.5"
multiformats: "npm:^13.1.0"
protons-runtime: "npm:^5.4.0"
uint8arraylist: "npm:^2.4.8"
uint8arrays: "npm:^5.0.3"
checksum: 10c0/17dc384be739cb0a22d46e059d0fb154ee3e99fb119319397805d7d29988cce45b4d8c7874a8e46b7d3a7c265e6ca9bd8fd26aad21196fa1741c6766ca307ae6
checksum: 10c0/b3bda92ce19c97b7e0993224d066c21d4f22556b0af725b6e5ba36998e5f1c4494010ac909d292aedb843b215edc86117b89a2f35a7ed65822164cd0829c3f20
languageName: node
linkType: hard

Expand Down Expand Up @@ -1804,18 +1782,6 @@ __metadata:
languageName: node
linkType: hard

"@libp2p/interface-internal@npm:^1.0.1, @libp2p/interface-internal@npm:^1.0.7, @libp2p/interface-internal@npm:^1.2.0":
version: 1.2.0
resolution: "@libp2p/interface-internal@npm:1.2.0"
dependencies:
"@libp2p/interface": "npm:^1.3.1"
"@libp2p/peer-collections": "npm:^5.2.0"
"@multiformats/multiaddr": "npm:^12.2.1"
uint8arraylist: "npm:^2.4.8"
checksum: 10c0/258044ab1a37f2341bfa41308b8c4fa0366d429cc90db7f5a088c43cfe9eaa2fe5324de30e7a16d2effa18614ada90108d703a1ba2a6ac67451349c75e7e013c
languageName: node
linkType: hard

"@libp2p/interface-internal@npm:^1.0.9":
version: 1.0.9
resolution: "@libp2p/interface-internal@npm:1.0.9"
Expand All @@ -1828,6 +1794,18 @@ __metadata:
languageName: node
linkType: hard

"@libp2p/interface-internal@npm:^1.2.0":
version: 1.2.0
resolution: "@libp2p/interface-internal@npm:1.2.0"
dependencies:
"@libp2p/interface": "npm:^1.3.1"
"@libp2p/peer-collections": "npm:^5.2.0"
"@multiformats/multiaddr": "npm:^12.2.1"
uint8arraylist: "npm:^2.4.8"
checksum: 10c0/258044ab1a37f2341bfa41308b8c4fa0366d429cc90db7f5a088c43cfe9eaa2fe5324de30e7a16d2effa18614ada90108d703a1ba2a6ac67451349c75e7e013c
languageName: node
linkType: hard

"@libp2p/interface@npm:^0.1.3, @libp2p/interface@npm:^0.1.6":
version: 0.1.6
resolution: "@libp2p/interface@npm:0.1.6"
Expand Down Expand Up @@ -1858,31 +1836,31 @@ __metadata:
languageName: node
linkType: hard

"@libp2p/interface@npm:^1.0.1, @libp2p/interface@npm:^1.3.1":
version: 1.3.1
resolution: "@libp2p/interface@npm:1.3.1"
"@libp2p/interface@npm:^1.1.2, @libp2p/interface@npm:^1.2.0":
version: 1.2.0
resolution: "@libp2p/interface@npm:1.2.0"
dependencies:
"@multiformats/multiaddr": "npm:^12.2.1"
it-pushable: "npm:^3.2.3"
it-stream-types: "npm:^2.0.1"
multiformats: "npm:^13.1.0"
progress-events: "npm:^1.0.0"
uint8arraylist: "npm:^2.4.8"
checksum: 10c0/739db26f4dad0cc18a5c707572e2a209335562a009fbb98314498b2d7a04f1db091f1663e22ffa6fec528a6293ec7e000a679f00c299c87a157eddf9e86a55ac
checksum: 10c0/0e59ba6be456047c65a072bbbb31f703dafb0d005d504bb10a3534656220fb15917c59c441d02fb5eb2bd1d3a5c98125b7bb591c9af110622f0089853ea7abf5
languageName: node
linkType: hard

"@libp2p/interface@npm:^1.1.2, @libp2p/interface@npm:^1.2.0":
version: 1.2.0
resolution: "@libp2p/interface@npm:1.2.0"
"@libp2p/interface@npm:^1.3.1":
version: 1.3.1
resolution: "@libp2p/interface@npm:1.3.1"
dependencies:
"@multiformats/multiaddr": "npm:^12.2.1"
it-pushable: "npm:^3.2.3"
it-stream-types: "npm:^2.0.1"
multiformats: "npm:^13.1.0"
progress-events: "npm:^1.0.0"
uint8arraylist: "npm:^2.4.8"
checksum: 10c0/0e59ba6be456047c65a072bbbb31f703dafb0d005d504bb10a3534656220fb15917c59c441d02fb5eb2bd1d3a5c98125b7bb591c9af110622f0089853ea7abf5
checksum: 10c0/739db26f4dad0cc18a5c707572e2a209335562a009fbb98314498b2d7a04f1db091f1663e22ffa6fec528a6293ec7e000a679f00c299c87a157eddf9e86a55ac
languageName: node
linkType: hard

Expand Down Expand Up @@ -2085,25 +2063,25 @@ __metadata:
languageName: node
linkType: hard

"@libp2p/peer-id@npm:^4.0.1, @libp2p/peer-id@npm:^4.0.5, @libp2p/peer-id@npm:^4.1.1":
version: 4.1.1
resolution: "@libp2p/peer-id@npm:4.1.1"
"@libp2p/peer-id@npm:^4.0.10":
version: 4.0.10
resolution: "@libp2p/peer-id@npm:4.0.10"
dependencies:
"@libp2p/interface": "npm:^1.3.1"
"@libp2p/interface": "npm:^1.2.0"
multiformats: "npm:^13.1.0"
uint8arrays: "npm:^5.0.3"
checksum: 10c0/0ac51989a5011f1919dcb1668b871d5598edb943952df9964c152a15e3f26887a1dcddb2704c8a6768b63f42444d58faab73bbd55059ad3ed9b8e38b76c6afe2
checksum: 10c0/b0e2da7692821398dc408b783d22efc971fafa8c6a8cc897f09054637557ea1724dc648968ac137e417c0c8681c5595c642cad18c7af33db6e9e2d54fb5809d6
languageName: node
linkType: hard

"@libp2p/peer-id@npm:^4.0.10":
version: 4.0.10
resolution: "@libp2p/peer-id@npm:4.0.10"
"@libp2p/peer-id@npm:^4.1.1":
version: 4.1.1
resolution: "@libp2p/peer-id@npm:4.1.1"
dependencies:
"@libp2p/interface": "npm:^1.2.0"
"@libp2p/interface": "npm:^1.3.1"
multiformats: "npm:^13.1.0"
uint8arrays: "npm:^5.0.3"
checksum: 10c0/b0e2da7692821398dc408b783d22efc971fafa8c6a8cc897f09054637557ea1724dc648968ac137e417c0c8681c5595c642cad18c7af33db6e9e2d54fb5809d6
checksum: 10c0/0ac51989a5011f1919dcb1668b871d5598edb943952df9964c152a15e3f26887a1dcddb2704c8a6768b63f42444d58faab73bbd55059ad3ed9b8e38b76c6afe2
languageName: node
linkType: hard

Expand Down Expand Up @@ -2193,42 +2171,6 @@ __metadata:
languageName: node
linkType: hard

"@libp2p/pubsub-peer-discovery@npm:^10.0.2":
version: 10.0.2
resolution: "@libp2p/pubsub-peer-discovery@npm:10.0.2"
dependencies:
"@libp2p/interface": "npm:^1.0.1"
"@libp2p/interface-internal": "npm:^1.0.1"
"@libp2p/peer-id": "npm:^4.0.1"
"@multiformats/multiaddr": "npm:^12.0.0"
protons-runtime: "npm:^5.0.0"
uint8arraylist: "npm:^2.4.3"
uint8arrays: "npm:^4.0.9"
checksum: 10c0/e9c0bfdc56abb5deafa0eaac6c15e89c6dc10ef4a288e351a760b0d6bce1b815142d2e99202daac695777b31ead657761f1c154cc72d060bf2962293a0e937f6
languageName: node
linkType: hard

"@libp2p/pubsub@npm:^9.0.8":
version: 9.0.17
resolution: "@libp2p/pubsub@npm:9.0.17"
dependencies:
"@libp2p/crypto": "npm:^4.1.1"
"@libp2p/interface": "npm:^1.3.1"
"@libp2p/interface-internal": "npm:^1.2.0"
"@libp2p/peer-collections": "npm:^5.2.0"
"@libp2p/peer-id": "npm:^4.1.1"
"@libp2p/utils": "npm:^5.4.0"
it-length-prefixed: "npm:^9.0.4"
it-pipe: "npm:^3.0.1"
it-pushable: "npm:^3.2.3"
multiformats: "npm:^13.1.0"
p-queue: "npm:^8.0.1"
uint8arraylist: "npm:^2.4.8"
uint8arrays: "npm:^5.0.3"
checksum: 10c0/9cefbe7e1cc09790812806c79a690ca7c2f897dc2971209120136b10db45f618f4b310967806a7e5f58ca74209fbeba3e2638e0d38c1b556bce61c33db5983df
languageName: node
linkType: hard

"@libp2p/tcp@npm:^9.0.16":
version: 9.0.16
resolution: "@libp2p/tcp@npm:9.0.16"
Expand Down Expand Up @@ -5688,13 +5630,6 @@ __metadata:
languageName: node
linkType: hard

"denque@npm:^2.1.0":
version: 2.1.0
resolution: "denque@npm:2.1.0"
checksum: 10c0/f9ef81aa0af9c6c614a727cb3bd13c5d7db2af1abf9e6352045b86e85873e629690f6222f4edd49d10e4ccf8f078bbeec0794fafaf61b659c0589d0c511ec363
languageName: node
linkType: hard

"depd@npm:2.0.0":
version: 2.0.0
resolution: "depd@npm:2.0.0"
Expand Down Expand Up @@ -7953,7 +7888,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "ipmc-desktop@workspace:packages/desktop"
dependencies:
"@chainsafe/libp2p-gossipsub": "npm:13.0.0"
"@chainsafe/libp2p-noise": "npm:^15.0.0"
"@electron-toolkit/eslint-config-prettier": "npm:^2.0.0"
"@electron-toolkit/eslint-config-ts": "npm:^2.0.0"
Expand All @@ -7963,9 +7897,7 @@ __metadata:
"@helia/ipns": "npm:^7.2.2"
"@helia/unixfs": "npm:^3.0.6"
"@libp2p/bootstrap": "npm:^10.0.22"
"@libp2p/identify": "npm:^2.0.0"
"@libp2p/pnet": "npm:^1.0.1"
"@libp2p/pubsub-peer-discovery": "npm:^10.0.2"
"@libp2p/tcp": "npm:^9.0.16"
"@libp2p/websockets": "npm:^8.0.16"
"@libp2p/webtransport": "npm:4.0.21"
Expand Down Expand Up @@ -10564,7 +10496,7 @@ __metadata:
languageName: node
linkType: hard

"protons-runtime@npm:5.4.0, protons-runtime@npm:^5.0.0, protons-runtime@npm:^5.2.1, protons-runtime@npm:^5.4.0":
"protons-runtime@npm:^5.0.0, protons-runtime@npm:^5.2.1, protons-runtime@npm:^5.4.0":
version: 5.4.0
resolution: "protons-runtime@npm:5.4.0"
dependencies:
Expand Down Expand Up @@ -12456,7 +12388,7 @@ __metadata:
languageName: node
linkType: hard

"uint8arrays@npm:^4.0.6, uint8arrays@npm:^4.0.9":
"uint8arrays@npm:^4.0.6":
version: 4.0.10
resolution: "uint8arrays@npm:4.0.10"
dependencies:
Expand Down

0 comments on commit c0f57f5

Please sign in to comment.