Conversation
|
@achingbrain any chance you could take a look at this one please? |
achingbrain
left a comment
There was a problem hiding this comment.
A few notes:
- Maybe make the routing table
.addmethod synchronous and encapsulate the update queuing logic inside the routing table class instead. The query manager seems like the wrong place to me. - If you use the
PeerQueueclass from@libp2p/utilsinstead of the genericQueueit will deduplicate jobs based on the passed PeerId for you (call.find(peerId)on the queue and then.join(opts)on the job if present). - Pass a
metricsinstance andmetricNameoption to theQueue/PeerQueueconstructor to have it show up in graphana (essential to tune parameters) - You can continue to use a queue after
.abort()is called on it, no need to have the queue field beQueue | undefinedin the containing class - just create it in the constructor as normal - Most of the routing table stats would be available to graphana via the built in metrics, it seems redundant to hold them in memory
- The routing table stats seem to be most useful for tests - consider using sinon spys instead
- There seems to be some duplicate logic around when to perform routing table updates - this is defined by the spec and the routing table already has an interval during which a peer will not be re-pinged
- "Routing" is an overloaded term in libp2p so the new config options should be fully qualified (e.g. routingTableUpdateQueueConcurrency)
| }))) { | ||
| continue | ||
| } | ||
|
|
There was a problem hiding this comment.
These conditionals probably all need to go and any results found should just be yielded.
A peer can be returned from a query without multiaddrs. It's not invalid, it just means that their multiaddrs have expired in the peerstore of the node returning the peer.
From memory I think multiaddr expiration was added in js after this code was written though it was present in go which is why peers were returned without multiaddrs which looked like an error.
If the calling code wants to dial the peer, it should execute a findPeer query to get updated multiaddrs before dialling (the dial queue already does this here).
| yield finalPeerEvent({ | ||
| from: this.components.peerId, | ||
| peer: await self.components.peerStore.getInfo(peer.id, options), | ||
| peer, |
There was a problem hiding this comment.
This is better, we should just yield the query result without modifying it.
|
Thanks @achingbrain for the feedback - Hopefully addressed all the issues although I didn't Also reduced the scope a bit by removing the peer TTL stuff and custom queue metrics. |
achingbrain
left a comment
There was a problem hiding this comment.
LGTM, tested locally & is much faster.
Couple of small comments inline.
| } | ||
| }, { | ||
| peerId, | ||
| signal: options.signal |
There was a problem hiding this comment.
The composite signal needs to be passed to the job.
| signal: options.signal | |
| signal |
| this.routingTableUpdateQueue = new PeerQueue<void>({ | ||
| concurrency: init.routingTableUpdateQueueConcurrency ?? ROUTING_TABLE_UPDATE_QUEUE_CONCURRENCY, | ||
| metricName: `${init.metricsPrefix}_routing_table_update_queue`, | ||
| metrics: this.components.metrics | ||
| }) |
There was a problem hiding this comment.
Should also allow configuring the maxSize parameter otherwise this can grow in an unbounded fashion.
Description
getClosestPeershot path so query progress/event streaming is not blocked.RoutingTableand use a dedicatedPeerQueuewith per-peer dedupe (find/join).onPeerConnect).routingTableUpdateQueueConcurrency.getClosestPeersto yield query results directly (no peer filtering/mutation).networkDialTimeout(thanks @paschal533).Change checklist