add comments

This commit is contained in:
Starbeamrainbowlabs 2022-02-21 03:14:41 +00:00
parent 3819f8c61a
commit de0b5893ac
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -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;