feat(network,routing): manually expand stack and advanced routing modules
- multipath-fanout: progress, cancelPending, pruneStale - protocol-handshake: negotiate, clearOffers - secret-stream-pair: createAndOpen, destroyActive - load-spread: pickTop, incrementLoad, removePeer, totalLoad - geo-hint-router: routeTopN, peersInRadius, listPeers Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -65,6 +65,28 @@ class HyperP2PMultipathFanout extends EventEmitter {
|
||||
return b4a.concat(parts)
|
||||
}
|
||||
|
||||
progress (msgId) {
|
||||
const p = this._pending.get(msgId)
|
||||
if (!p) return null
|
||||
return { received: p.shards.size, total: p.total, ratio: p.shards.size / p.total }
|
||||
}
|
||||
|
||||
cancelPending (msgId) {
|
||||
return this._pending.delete(msgId)
|
||||
}
|
||||
|
||||
pruneStale (maxAgeMs = 60000) {
|
||||
const cutoff = Date.now() - maxAgeMs
|
||||
let n = 0
|
||||
for (const [id, p] of this._pending) {
|
||||
if ((p.createdAt || 0) < cutoff) {
|
||||
this._pending.delete(id)
|
||||
n++
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
getStats () {
|
||||
return { ...this._stats, pending: this._pending.size, protocol: PROTOCOL }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user