From d650283fdef319af2f0f17dff6733d6d6eb5c59d Mon Sep 17 00:00:00 2001 From: Oak Date: Tue, 2 Jul 2024 18:36:24 +0100 Subject: [PATCH] fix: rm runOnTransientConnections (#35) --- examples/canvas/yarn.lock | 34 +++++++++++++++++----------------- packages/network/src/node.ts | 21 ++++----------------- 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/examples/canvas/yarn.lock b/examples/canvas/yarn.lock index 0cc67a4e..d35913b9 100644 --- a/examples/canvas/yarn.lock +++ b/examples/canvas/yarn.lock @@ -17,7 +17,7 @@ resolved "https://registry.yarnpkg.com/@chainsafe/is-ip/-/is-ip-2.0.2.tgz#7311e7403f11d8c5cfa48111f56fcecaac37c9f6" integrity sha512-ndGqEMG1W5WkGagaqOZHpPU172AGdxr+LD15sv3WIUvT5oCFUrG1Y0CW/v2Egwj4JXEvSibaIIIqImsm98y1nA== -"@chainsafe/libp2p-gossipsub@^13.0.0": +"@chainsafe/libp2p-gossipsub@^13.1.0": version "13.1.0" resolved "https://registry.yarnpkg.com/@chainsafe/libp2p-gossipsub/-/libp2p-gossipsub-13.1.0.tgz#b0c2d84c334dc1bcbd67cb379c7f0a0feca6a4c1" integrity sha512-Wk1O6ZT/L0o+p9vlAB4qxDa9pAwTh5yxPrQbyc98wvKbrnPhAfZbjMfhCBOEvFKzMkEFDsTd3TGPjP8TTtNtQw== @@ -37,7 +37,7 @@ uint8arraylist "^2.4.8" uint8arrays "^5.0.1" -"@chainsafe/libp2p-noise@^15.0.0": +"@chainsafe/libp2p-noise@^15.0.0", "@chainsafe/libp2p-noise@^15.1.0": version "15.1.0" resolved "https://registry.yarnpkg.com/@chainsafe/libp2p-noise/-/libp2p-noise-15.1.0.tgz#f30caa146d3d11c6dfd6da3c4510b664f8b0881c" integrity sha512-84S/Uk7ZZRYpSlE5d1odMmQTl5g5Da8etgcf4QI7arTAHkvBs3il7yGHIPt4wV4EV0qIMG+XjdGIYihRXfI2/w== @@ -624,14 +624,14 @@ resolved "https://registry.yarnpkg.com/@sindresorhus/fnv1a/-/fnv1a-3.1.0.tgz#f8e46597298f6fd4c12dc901cdd4e73beb4d24fa" integrity sha512-KV321z5m/0nuAg83W1dPLy85HpHDk7Sdi4fJbwvacWsEhAh+rZUW4ZfGcXmUIvjZg4ss2bcwNlRhJ7GBEUG08w== -"@topology-foundation/crdt@0.0.11", "@topology-foundation/crdt@file:../../packages/crdt": - version "0.0.11" +"@topology-foundation/crdt@0.0.12", "@topology-foundation/crdt@file:../../packages/crdt": + version "0.0.12" -"@topology-foundation/network@0.0.11", "@topology-foundation/network@file:../../packages/network": - version "0.0.11" +"@topology-foundation/network@0.0.12", "@topology-foundation/network@file:../../packages/network": + version "0.0.12" dependencies: - "@chainsafe/libp2p-gossipsub" "^13.0.0" - "@chainsafe/libp2p-noise" "^15.0.0" + "@chainsafe/libp2p-gossipsub" "^13.1.0" + "@chainsafe/libp2p-noise" "^15.1.0" "@chainsafe/libp2p-yamux" "^6.0.2" "@libp2p/autonat" "^1.0.0" "@libp2p/bootstrap" "^10.1.0" @@ -648,20 +648,20 @@ libp2p "^1.6.0" "@topology-foundation/node@file:../../packages/node": - version "0.0.11" + version "0.0.12" dependencies: "@libp2p/dcutr" "^1.1.0" - "@topology-foundation/crdt" "0.0.11" - "@topology-foundation/network" "0.0.11" - "@topology-foundation/object" "0.0.11" + "@topology-foundation/crdt" "0.0.12" + "@topology-foundation/network" "0.0.12" + "@topology-foundation/object" "0.0.12" -"@topology-foundation/object@0.0.11": - version "0.0.11" - resolved "https://registry.yarnpkg.com/@topology-foundation/object/-/object-0.0.11.tgz#eefc084ad1231d01340e31a400223944178ae207" - integrity sha512-zIXzu6U1FYwEXBqCht/JBo71RNC5tL2wJbo5qI6WeotHpNYLpcCM/X0y7M+fvKQtdyb/vJRf2FjwIjqA1knI9g== +"@topology-foundation/object@0.0.12": + version "0.0.12" + resolved "https://registry.yarnpkg.com/@topology-foundation/object/-/object-0.0.12.tgz#af8e7852ca959b5db36a8147dc9741baf3a6eadd" + integrity sha512-RCu9gbVoqhYQpCZtwlxp9055M4ZJAXoixQc0ZUZaap1iTFc7mtN4RByQdW71iWIl3l9DWNEjNA8cBu+jbR/sEw== "@topology-foundation/object@file:../../packages/object": - version "0.0.11" + version "0.0.12" "@tsconfig/node10@^1.0.7": version "1.0.11" diff --git a/packages/network/src/node.ts b/packages/network/src/node.ts index af229057..2df3e92b 100644 --- a/packages/network/src/node.ts +++ b/packages/network/src/node.ts @@ -10,15 +10,12 @@ import { dcutr } from "@libp2p/dcutr"; import { identify } from "@libp2p/identify"; import { EventHandler, PubSub, Stream, StreamHandler } from "@libp2p/interface"; import { pubsubPeerDiscovery } from "@libp2p/pubsub-peer-discovery"; -import { webRTC, webRTCDirect } from "@libp2p/webrtc"; +import { webRTC } from "@libp2p/webrtc"; import { webSockets } from "@libp2p/websockets"; import { multiaddr } from "@multiformats/multiaddr"; import { Libp2p, createLibp2p } from "libp2p"; import { stringToStream } from "./stream.js"; -import { webTransport } from "@libp2p/webtransport"; import { bootstrap } from "@libp2p/bootstrap"; -import { fromString as uint8ArrayFromString } from "uint8arrays/from-string"; -import { toString as uint8ArrayToString } from "uint8arrays/to-string"; export interface TopologyNetworkNodeConfig {} @@ -36,10 +33,7 @@ export class TopologyNetworkNode { async start() { this._node = await createLibp2p({ addresses: { - listen: [ - "/webrtc", - "/dns4/relay.droak.sh/tcp/443/wss/p2p/Qma3GsJmB47xYuyahPZPSadh1avvxfyYQwk8R3UnFrQ6aP/p2p-circuit", - ], + listen: ["/webrtc"], }, connectionEncryption: [noise()], connectionGater: { @@ -62,7 +56,6 @@ export class TopologyNetworkNode { identify: identify(), pubsub: gossipsub({ allowPublishToZeroTopicPeers: true, - // runOnTransientConnection: true, }), dcutr: dcutr(), }, @@ -85,9 +78,7 @@ export class TopologyNetworkNode { ], }, }), - webRTCDirect(), webSockets(), - webTransport(), ], }); @@ -180,9 +171,7 @@ export class TopologyNetworkNode { async sendMessage(peerId: string, protocols: string[], message: string) { try { const connection = await this._node?.dial([multiaddr(`/p2p/${peerId}`)]); - const stream = await connection?.newStream(protocols, { - // runOnTransientConnection: true, - }); + const stream = await connection?.newStream(protocols); stringToStream(stream, message); console.log( @@ -204,9 +193,7 @@ export class TopologyNetworkNode { const peerId = peers[Math.floor(Math.random() * peers.length)]; const connection = await this._node?.dial(peerId); - const stream: Stream = (await connection?.newStream(protocols, { - // runOnTransientConnection: true, - })) as Stream; + const stream: Stream = (await connection?.newStream(protocols)) as Stream; stringToStream(stream, message); console.log(