Expand pear, encoding, consensus, supercomputer, and CRDT modules
Add manual API helpers across categories: pear link resolver cache, applink reload, storage layout defaults, compact codec decodeBatch, schema allValid/getSchema, session bridge removePair, udx sendRecvRatio, cluster affinity and cpu-share clearAll, raft truncateLog/currentTerm, quorum vote tally, silence and whisper seen helpers, qos unsubscribeAll, LWW register clearAll, peer selector topRegions, graph hasPath, fork choice clearViews, and trust gate untrustAll. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -100,6 +100,18 @@ class HyperP2PPeerSelectorStreaming extends EventEmitter {
|
||||
return this._peers.size
|
||||
}
|
||||
|
||||
topRegions (limit = 5) {
|
||||
const counts = new Map()
|
||||
for (const p of this._peers.values()) {
|
||||
const r = p.region || 'unknown'
|
||||
counts.set(r, (counts.get(r) || 0) + 1)
|
||||
}
|
||||
return [...counts.entries()]
|
||||
.sort((a, b) => b[1] - a[1])
|
||||
.slice(0, Math.max(0, limit | 0))
|
||||
.map(([region, count]) => ({ region, count }))
|
||||
}
|
||||
|
||||
getStats () {
|
||||
return mediaStats(this._stats, PROTOCOL, { peers: this._peers.size })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user