Skip to content

Commit

Permalink
fix: rm runOnTransientConnections (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-roak authored Jul 2, 2024
1 parent f3c254f commit d650283
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 34 deletions.
34 changes: 17 additions & 17 deletions examples/canvas/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand All @@ -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==
Expand Down Expand Up @@ -624,14 +624,14 @@
resolved "https://registry.yarnpkg.com/@sindresorhus/fnv1a/-/fnv1a-3.1.0.tgz#f8e46597298f6fd4c12dc901cdd4e73beb4d24fa"
integrity sha512-KV321z5m/0nuAg83W1dPLy85HpHDk7Sdi4fJbwvacWsEhAh+rZUW4ZfGcXmUIvjZg4ss2bcwNlRhJ7GBEUG08w==

"@topology-foundation/[email protected].11", "@topology-foundation/crdt@file:../../packages/crdt":
version "0.0.11"
"@topology-foundation/[email protected].12", "@topology-foundation/crdt@file:../../packages/crdt":
version "0.0.12"

"@topology-foundation/[email protected].11", "@topology-foundation/network@file:../../packages/network":
version "0.0.11"
"@topology-foundation/[email protected].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"
Expand All @@ -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/[email protected].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/[email protected].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"
Expand Down
21 changes: 4 additions & 17 deletions packages/network/src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand All @@ -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: {
Expand All @@ -62,7 +56,6 @@ export class TopologyNetworkNode {
identify: identify(),
pubsub: gossipsub({
allowPublishToZeroTopicPeers: true,
// runOnTransientConnection: true,
}),
dcutr: dcutr(),
},
Expand All @@ -85,9 +78,7 @@ export class TopologyNetworkNode {
],
},
}),
webRTCDirect(),
webSockets(),
webTransport(),
],
});

Expand Down Expand Up @@ -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 = <Stream>await connection?.newStream(protocols, {
// runOnTransientConnection: true,
});
const stream = <Stream>await connection?.newStream(protocols);
stringToStream(stream, message);

console.log(
Expand All @@ -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(
Expand Down

0 comments on commit d650283

Please sign in to comment.