I think i got it to work lol

This commit is contained in:
MrMasrozYTLIVE 2024-06-10 21:17:16 +03:00
parent 27b3528304
commit 4ec0be2774

View File

@ -23,10 +23,15 @@ class Client extends EventEmitter {
this.swarm.on('update', () => {
console.log(`Connections count: ${this.swarm.connections.size} / Peers count: ${this.swarm.peers.size}`);
this.swarm.peers.forEach((peerInfo, peer) => {
console.log(`Peer ${[peer]} is in topic(s) [${[peerInfo.topics].filter(topic => topic).map(topic => {
console.log(topic.map(top => b4a.toString(top, 'hex')))
}).join(", ")}]`);
this.swarm.peers.forEach((peerInfo, peerId) => {
// Please do not try to understand what is going on here. I have no idea anyway. But it surprisingly works
const peer = [peerId];
const peerTopics = [peerInfo.topics].filter(topic => topic)
.map(topic => topic.map(top => b4a.toString(top, 'hex')))
.join(", ");
console.log(`Peer ${peer} is in topic(s) [${peerTopics}]`);
});
});
}