From de0b5893ac54096701cb64e63f7579ad797298c3 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Mon, 21 Feb 2022 03:14:41 +0000 Subject: [PATCH] add comments --- src/lib/SystemQuery.mjs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/SystemQuery.mjs b/src/lib/SystemQuery.mjs index 517ca16..004ecd4 100644 --- a/src/lib/SystemQuery.mjs +++ b/src/lib/SystemQuery.mjs @@ -69,7 +69,7 @@ class SystemQuery extends EventEmitter { async *fetch_table(name) { // If it isn't valid for us, it ain't gonna be valid for anyone else.... if(!this.info.is_valid_table(name)) return null; - l.log(`fetch table ${name} start`) + const queue = new ItemQueue(); const handle_response = (peer, msg) => { @@ -95,9 +95,13 @@ class SystemQuery extends EventEmitter { // we do not drop any messages due to the use of the ItemQueue. this.agent.broadcast(`query`, { name }); + + // TODO: Yield a table value for us too + // TODO: Handle duplicate connections better by both skipping counting them here, and also implementing a more robust reaper for killing duplicate connections that always kills the newest/oldest connection to avoid issues. + let peers_seen = []; while(peers_seen.length < this.agent.connected_peers.length) { - l.info(`peers_seen:`, peers_seen, `connected peers:`, this.agent.connected_peers.length); + l.info(`peers_seen:`, peers_seen, `connected peers:`, this.agent.connected_peers.map(peer => peer.id)); let next = await queue.dequeue(this.config.net.table_timeout * 1000); if(typeof next === "undefined") // We timed out break;