I actually didnt fix the issue with array of arrays. Now it should be fine

This commit is contained in:
MrMasrozYTLIVE 2024-06-10 18:03:15 +03:00
parent ecfc62ff2c
commit d993090f8b
2 changed files with 3 additions and 2 deletions

3
app.js
View File

@ -297,7 +297,8 @@ function sendMessage(e) {
onMessageAdded(config.userName, message, config.userAvatar); onMessageAdded(config.userName, message, config.userAvatar);
let peersPublicKeys = []; let peersPublicKeys = [];
peersPublicKeys.push([...swarm.connections].map(peer => peer.remotePublicKey.toString('hex')).flat(1)); peersPublicKeys.push([...swarm.connections].map(peer => peer.remotePublicKey.toString('hex')));
peersPublicKeys = peersPublicKeys.flat(1);
peersPublicKeys.push(swarm.keyPair.publicKey.toString('hex')); peersPublicKeys.push(swarm.keyPair.publicKey.toString('hex'));
const messageObj = JSON.stringify({ const messageObj = JSON.stringify({

View File

@ -22,7 +22,7 @@ class Client extends EventEmitter {
this.swarm.on('update', () => { this.swarm.on('update', () => {
console.log(`Peers count: ${this.swarm.connections.size}`); console.log(`Peers count: ${this.swarm.connections.size}`);
if(this.swarm.connections.size > 0) { if(this.swarm.connections.size > 0) {
let peers = [...this.swarm.peers].filter(peer => peer && peer.publicKey && peer.publicKey.toString('hex').startsWith("51be150")) let peers = [...this.swarm.peers].filter(peer => peer && peer.publicKey && peer.publicKey.toString('hex').startsWith("a4eb7f"))
if(peers.length > 0) { if(peers.length > 0) {
console.log(peers[0]) console.log(peers[0])
console.log([peers[0].topics]); console.log([peers[0].topics]);