Add listKeys() and keyCount() helpers across modules (ninth pass).

Standardize key enumeration after size() on map- and registry-style modules, aliasing existing list* methods or primary store keys so callers can inspect occupancy without parsing snapshots.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-21 05:23:43 -04:00
co-authored by Cursor
parent de89303380
commit 7f4f31d4d4
118 changed files with 945 additions and 0 deletions
@@ -470,6 +470,14 @@ class HyperP2PAgentMemory extends EventEmitter {
return this.memoryCount() return this.memoryCount()
} }
listKeys () {
return this.memoryIds()
}
keyCount () {
return this.size()
}
async storeMemoryBatch (entries) { async storeMemoryBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
const out = [] const out = []
@@ -475,6 +475,14 @@ class HyperP2PTaskOrchestrator extends EventEmitter {
return this.tasks.size return this.tasks.size
} }
listKeys () {
return this.listTaskIds()
}
keyCount () {
return this.size()
}
getStats () { getStats () {
const counts = this.taskCounts() const counts = this.taskCounts()
return { return {
@@ -205,6 +205,14 @@ class HyperP2PWorkflowGraph extends EventEmitter {
return this.nodeCount() return this.nodeCount()
} }
listKeys () {
return this.nodeIds()
}
keyCount () {
return this.size()
}
nodeIds () { nodeIds () {
return [...this._nodes.keys()] return [...this._nodes.keys()]
} }
@@ -184,6 +184,14 @@ class HyperP2PCollabRoom extends EventEmitter {
return this.roomCount() return this.roomCount()
} }
listKeys () {
return this.listRooms()
}
keyCount () {
return this.size()
}
_onGossip (data) { _onGossip (data) {
if (!data || !data.type) return if (!data || !data.type) return
this._stats.gossipIn++ this._stats.gossipIn++
@@ -130,6 +130,14 @@ class HyperP2PCursorPresence extends EventEmitter {
return this.cursorCount() return this.cursorCount()
} }
listKeys () {
return this.listDocIds()
}
keyCount () {
return this.size()
}
_onGossip (data) { _onGossip (data) {
if (!data) return if (!data) return
this._stats.gossipIn++ this._stats.gossipIn++
@@ -124,6 +124,14 @@ class HyperP2PDocumentLineLock extends EventEmitter {
return this.lockCount() return this.lockCount()
} }
listKeys () {
return [...this._locks.keys()]
}
keyCount () {
return this.size()
}
acquireBatch (entries) { acquireBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.acquire(e.docId, e.line)) return entries.map((e) => this.acquire(e.docId, e.line))
@@ -122,6 +122,14 @@ class HyperP2PWhiteboardOp extends EventEmitter {
return this.opCount() return this.opCount()
} }
listKeys () {
return this.listRooms()
}
keyCount () {
return this.size()
}
applyBatch (entries) { applyBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.apply(e.roomId, e.op)) return entries.map((e) => this.apply(e.roomId, e.op))
@@ -157,6 +157,14 @@ class HyperP2PAuctionGossip extends EventEmitter {
return this.snapshot().auctions return this.snapshot().auctions
} }
listKeys () {
return this.listAuctionIds()
}
keyCount () {
return this.size()
}
openAuctionBatch (entries) { openAuctionBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.openAuction(e.auctionId, e.meta || {})) return entries.map((e) => this.openAuction(e.auctionId, e.meta || {}))
@@ -126,6 +126,14 @@ class HyperP2PCreditLedger extends EventEmitter {
return this.accountCount() return this.accountCount()
} }
listKeys () {
return this.listAccounts()
}
keyCount () {
return this.size()
}
_apply (accountId, delta, kind, reason) { _apply (accountId, delta, kind, reason) {
assertNonEmpty(accountId, 'accountId') assertNonEmpty(accountId, 'accountId')
const acct = this._accounts.get(accountId) const acct = this._accounts.get(accountId)
@@ -137,6 +137,14 @@ class HyperP2PMarketplaceListing extends EventEmitter {
return this.snapshot().listings return this.snapshot().listings
} }
listKeys () {
return this.listListingIds()
}
keyCount () {
return this.size()
}
createListingBatch (entries) { createListingBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.createListing(e.listingId, e.listing)) return entries.map((e) => this.createListing(e.listingId, e.listing))
@@ -453,6 +453,14 @@ class HyperP2PCausalConsensus extends EventEmitter {
return this.proposals.size + this.decidedOrders.size return this.proposals.size + this.decidedOrders.size
} }
listKeys () {
return [...new Set([...this.proposals.keys(), ...this.decidedOrders.keys()])]
}
keyCount () {
return this.size()
}
async proposeBatch (entries) { async proposeBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
const out = [] const out = []
@@ -394,6 +394,14 @@ class HyperP2PDistributedLock extends EventEmitter {
return this.lockCount() return this.lockCount()
} }
listKeys () {
return [...this.locks.keys()]
}
keyCount () {
return this.size()
}
async acquireBatch (entries) { async acquireBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
const out = [] const out = []
@@ -168,6 +168,16 @@ class HyperP2PLeaderLease extends EventEmitter {
return this.followerCount() + (this._leader ? 1 : 0) return this.followerCount() + (this._leader ? 1 : 0)
} }
listKeys () {
const keys = this.followers()
if (this._leader) keys.push(this._leader)
return keys
}
keyCount () {
return this.size()
}
_gossipSync () { _gossipSync () {
gossipSend(this, { gossipSend(this, {
type: 'leader-lease-sync', type: 'leader-lease-sync',
@@ -218,6 +218,14 @@ class HyperP2PQuorumPool extends EventEmitter {
return this.proposalCount() return this.proposalCount()
} }
listKeys () {
return [...this._proposals.keys()]
}
keyCount () {
return this.size()
}
proposeBatch (payloads, opts = {}) { proposeBatch (payloads, opts = {}) {
if (!Array.isArray(payloads)) throw new Error('payloads array required') if (!Array.isArray(payloads)) throw new Error('payloads array required')
return payloads.map((payload) => this.propose(payload, opts)) return payloads.map((payload) => this.propose(payload, opts))
@@ -289,6 +289,14 @@ class CapabilityManager extends EventEmitter {
return s.issued + s.received + s.revoked return s.issued + s.received + s.revoked
} }
listKeys () {
return [...this.issued.keys(), ...this.received.keys()]
}
keyCount () {
return this.size()
}
issueBatch (entries) { issueBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.issue(e.subjectPubKey, e.resource, e.actions, e.ttlMs)) return entries.map((e) => this.issue(e.subjectPubKey, e.resource, e.actions, e.ttlMs))
@@ -372,6 +372,14 @@ class HyperP2PPresence extends EventEmitter {
return Math.max(0, this.peers.size - 1) return Math.max(0, this.peers.size - 1)
} }
listKeys () {
return this.peerIds()
}
keyCount () {
return this.size()
}
announceNow () { announceNow () {
this._broadcastPresence() this._broadcastPresence()
return this.getSelf() return this.getSelf()
@@ -168,6 +168,14 @@ class RPCServer extends EventEmitter {
return this.connectionCount() + this.pendingCount() return this.connectionCount() + this.pendingCount()
} }
listKeys () {
return this.listServices()
}
keyCount () {
return this.size()
}
connectionCount () { return this.connections.size } connectionCount () { return this.connections.size }
getStats () { getStats () {
@@ -105,6 +105,14 @@ class HyperP2PSessionBridge extends EventEmitter {
return this.pairCount() return this.pairCount()
} }
listKeys () {
return this.listPairs()
}
keyCount () {
return this.size()
}
async createPairBatch (count = 1) { async createPairBatch (count = 1) {
const n = Math.max(1, count | 0) const n = Math.max(1, count | 0)
const out = [] const out = []
@@ -365,6 +365,14 @@ class HyperP2PVectorClock extends EventEmitter {
return this.peerCount() return this.peerCount()
} }
listKeys () {
return this.peerIds()
}
keyCount () {
return this.size()
}
clearAll () { clearAll () {
const n = this.clock.size const n = this.clock.size
this.clock.clear() this.clock.clear()
@@ -130,6 +130,14 @@ class HyperP2PSchemaValidator extends EventEmitter {
return this.listSchemas().length return this.listSchemas().length
} }
listKeys () {
return this.listSchemas()
}
keyCount () {
return this.size()
}
registerSchemaBatch (entries) { registerSchemaBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.register(e.name, e.schema)) return entries.map((e) => this.register(e.name, e.schema))
@@ -166,6 +166,14 @@ class HyperP2PWireRegistry extends EventEmitter {
return this._codecs.size + this._protocols.size return this._codecs.size + this._protocols.size
} }
listKeys () {
return [...this.listCodecs(), ...this.listProtocols()]
}
keyCount () {
return this.size()
}
clearAll () { clearAll () {
const codecs = this.clearAllCodecs() const codecs = this.clearAllCodecs()
const protocols = this.unregisterAllProtocols() const protocols = this.unregisterAllProtocols()
@@ -120,6 +120,14 @@ class HyperP2PMemeticSpread extends EventEmitter {
return this.snapshot().totalMemes return this.snapshot().totalMemes
} }
listKeys () {
return this.listMemeIds()
}
keyCount () {
return this.size()
}
_gossip (data) { _gossip (data) {
if (!this._peerMsgs) return if (!this._peerMsgs) return
gossipSend(this, data) gossipSend(this, data)
@@ -115,6 +115,14 @@ class HyperP2PParadoxMerge extends EventEmitter {
return s.open + s.resolved return s.open + s.resolved
} }
listKeys () {
return [...this.listOpen(), ...this._resolved.keys()]
}
keyCount () {
return this.size()
}
branchBatch (entries) { branchBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.branch(e.id, e.value)) return entries.map((e) => this.branch(e.id, e.value))
@@ -124,6 +124,14 @@ class HyperP2PPhaseShiftClock extends EventEmitter {
return Object.keys(this.snapshot().peers).length return Object.keys(this.snapshot().peers).length
} }
listKeys () {
return Object.keys(this.snapshot().peers)
}
keyCount () {
return this.size()
}
shiftBatch (entries) { shiftBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.shift(e.phaseMs)) return entries.map((e) => this.shift(e.phaseMs))
@@ -134,6 +134,14 @@ class HyperP2PPheromoneTrail extends EventEmitter {
return this.trailCount() return this.trailCount()
} }
listKeys () {
return this.listPathIds()
}
keyCount () {
return this.size()
}
depositBatch (entries) { depositBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.deposit(e.pathId, e.strength, e.dest)) return entries.map((e) => this.deposit(e.pathId, e.strength, e.dest))
@@ -128,6 +128,14 @@ class HyperP2PSilenceProtocol extends EventEmitter {
return this.listAbsent().length return this.listAbsent().length
} }
listKeys () {
return this.listAbsent()
}
keyCount () {
return this.size()
}
async ready () { async ready () {
if (this.swarm || !this.topic) return this if (this.swarm || !this.topic) return this
await initModuleSwarm(this, { await initModuleSwarm(this, {
@@ -172,6 +172,14 @@ class HyperP2PTimeCapsule extends EventEmitter {
return this.snapshot().total return this.snapshot().total
} }
listKeys () {
return this.listIds()
}
keyCount () {
return this.size()
}
sealBatch (entries) { sealBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.seal(e.payload, e.opts || {})) return entries.map((e) => this.seal(e.payload, e.opts || {}))
@@ -100,6 +100,14 @@ class HyperP2PVoidChannel extends EventEmitter {
return this.snapshot().voids.length return this.snapshot().voids.length
} }
listKeys () {
return this.listChannels()
}
keyCount () {
return this.size()
}
unsubscribeAll () { unsubscribeAll () {
const n = this._subs.size const n = this._subs.size
this._subs.clear() this._subs.clear()
@@ -122,6 +122,10 @@ class HyperP2PBloomGossip extends EventEmitter {
return this.snapshot().size === 0 return this.snapshot().size === 0
} }
keyCount () {
return this.size()
}
addBatch (keys) { addBatch (keys) {
if (!Array.isArray(keys)) throw new Error('keys array required') if (!Array.isArray(keys)) throw new Error('keys array required')
return keys.map((k) => this.add(k)) return keys.map((k) => this.add(k))
@@ -173,6 +173,14 @@ class HyperP2PFulltextLite extends EventEmitter {
return this.snapshot().documents return this.snapshot().documents
} }
listKeys () {
return this.listDocuments()
}
keyCount () {
return this.size()
}
searchBatch (queries, mode = 'and') { searchBatch (queries, mode = 'and') {
if (!Array.isArray(queries)) throw new Error('queries array required') if (!Array.isArray(queries)) throw new Error('queries array required')
return queries.map((q) => this.search(q, mode)) return queries.map((q) => this.search(q, mode))
@@ -171,6 +171,14 @@ class HyperP2PGraphIndex extends EventEmitter {
return this.snapshot().edges.length return this.snapshot().edges.length
} }
listKeys () {
return this.nodes()
}
keyCount () {
return this.size()
}
addEdgeBatch (edges) { addEdgeBatch (edges) {
if (!Array.isArray(edges)) throw new Error('edges array required') if (!Array.isArray(edges)) throw new Error('edges array required')
return edges.map((e) => this.addEdge(e.from, e.to)) return edges.map((e) => this.addEdge(e.from, e.to))
@@ -150,6 +150,14 @@ class HyperP2PInvertedIndex extends EventEmitter {
return this.snapshot().documents return this.snapshot().documents
} }
listKeys () {
return [...this._docs.keys()]
}
keyCount () {
return this.size()
}
indexBatch (entries) { indexBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.index(e.docId, e.terms)) return entries.map((e) => this.index(e.docId, e.terms))
@@ -666,6 +666,15 @@ class HyperP2PSemanticVectorIndex extends EventEmitter {
const s = await this.snapshot() const s = await this.snapshot()
return s.vectorIds return s.vectorIds
} }
async listKeys () {
return this.vectorIds()
}
async keyCount () {
const s = await this.snapshot()
return s.vectorIds
}
} }
module.exports = HyperP2PSemanticVectorIndex module.exports = HyperP2PSemanticVectorIndex
@@ -192,6 +192,14 @@ class HyperP2PSimilarityLsh extends EventEmitter {
return s.vectors + s.buckets return s.vectors + s.buckets
} }
listKeys () {
return this.listIds()
}
keyCount () {
return this.size()
}
getStats () { getStats () {
return { return {
...this._stats, ...this._stats,
@@ -149,6 +149,14 @@ class HyperP2PTriePrefix extends EventEmitter {
return this.snapshot().words return this.snapshot().words
} }
listKeys () {
return this.list()
}
keyCount () {
return this.size()
}
getStats () { getStats () {
return { return {
...this._stats, ...this._stats,
@@ -297,6 +297,15 @@ class SpatialIndex extends EventEmitter {
return s.points return s.points
} }
async listKeys () {
return [...this.localPoints.keys()]
}
async keyCount () {
const s = await this.snapshot()
return s.points
}
getStats () { getStats () {
return { return {
...this._stats, ...this._stats,
@@ -56,6 +56,14 @@ class HyperP2PBucketRateLimit extends EventEmitter {
return Object.keys(this.snapshot().buckets).length return Object.keys(this.snapshot().buckets).length
} }
listKeys () {
return Object.keys(this.snapshot().buckets)
}
keyCount () {
return this.size()
}
_bucketSnapshot () { _bucketSnapshot () {
const out = {} const out = {}
for (const [peerId, b] of this._buckets) { for (const [peerId, b] of this._buckets) {
@@ -108,6 +108,14 @@ class HyperP2PHistogramGossip extends EventEmitter {
return this._metrics.size return this._metrics.size
} }
listKeys () {
return [...this._metrics.keys()]
}
keyCount () {
return this.size()
}
toJSON () { toJSON () {
return this.moduleSnapshot() return this.moduleSnapshot()
} }
@@ -127,6 +127,14 @@ class HyperP2PSlaBudget extends EventEmitter {
return this.serviceCount() return this.serviceCount()
} }
listKeys () {
return this.services()
}
keyCount () {
return this.size()
}
toJSON () { toJSON () {
return this.moduleSnapshot() return this.moduleSnapshot()
} }
@@ -151,6 +151,14 @@ class HyperP2PBandwidthAggregator extends EventEmitter {
return this.sourceCount() return this.sourceCount()
} }
listKeys () {
return this.peerIds()
}
keyCount () {
return this.size()
}
sourceCount () { sourceCount () {
return this._sources.size return this._sources.size
} }
@@ -129,6 +129,10 @@ class HyperP2PContentProtection extends EventEmitter {
return this.keyCount() return this.keyCount()
} }
listKeys () {
return [...this._keys.keys()]
}
getStats () { getStats () {
return mediaStats(this._stats, PROTOCOL, { activeKeyId: this._activeKeyId, keys: this._keys.size }) return mediaStats(this._stats, PROTOCOL, { activeKeyId: this._activeKeyId, keys: this._keys.size })
} }
@@ -118,6 +118,14 @@ class HyperP2PContributionLedger extends EventEmitter {
return this.snapshot().contributors return this.snapshot().contributors
} }
listKeys () {
return this.peerIds()
}
keyCount () {
return this.size()
}
_gossip (payload) { _gossip (payload) {
if (this._peerMsgs) { if (this._peerMsgs) {
gossipSend(this, payload) gossipSend(this, payload)
@@ -138,6 +138,14 @@ class HyperP2PEnterpriseOrchestrator extends EventEmitter {
return this.snapshot().count return this.snapshot().count
} }
listKeys () {
return this.listRegions()
}
keyCount () {
return this.size()
}
getStats () { getStats () {
return mediaStats(this._stats, PROTOCOL, { regions: this._regions.size }) return mediaStats(this._stats, PROTOCOL, { regions: this._regions.size })
} }
@@ -127,6 +127,14 @@ class HyperP2PFecVideo extends EventEmitter {
return this.snapshot().groups return this.snapshot().groups
} }
listKeys () {
return this.listGroupIds()
}
keyCount () {
return this.size()
}
getStats () { getStats () {
return mediaStats(this._stats, PROTOCOL, { groups: this._groups.size }) return mediaStats(this._stats, PROTOCOL, { groups: this._groups.size })
} }
@@ -137,6 +137,14 @@ class HyperP2PHelperSwarmCoordinator extends EventEmitter {
return this.snapshot().helpers return this.snapshot().helpers
} }
listKeys () {
return this.listViewers()
}
keyCount () {
return this.size()
}
registerHelperBatch (entries) { registerHelperBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.registerHelper(e.peerId, e.capacityBps)) return entries.map((e) => this.registerHelper(e.peerId, e.capacityBps))
@@ -115,6 +115,14 @@ class HyperP2PLatencyOptimizer extends EventEmitter {
return this.snapshot().paths return this.snapshot().paths
} }
listKeys () {
return this.listPathIds()
}
keyCount () {
return this.size()
}
measureBatch (entries) { measureBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries must be an array') if (!Array.isArray(entries)) throw new Error('entries must be an array')
return entries.map((e) => this.measurePath(e.pathId, e.hops || [])) return entries.map((e) => this.measurePath(e.pathId, e.hops || []))
@@ -116,6 +116,14 @@ class HyperP2PLiveEdgeManager extends EventEmitter {
return this.snapshot().count return this.snapshot().count
} }
listKeys () {
return this.listEdges()
}
keyCount () {
return this.size()
}
setLiveEdgeBatch (entries) { setLiveEdgeBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.setLiveEdge(e.streamId, e.seq, e.wallAt)) return entries.map((e) => this.setLiveEdge(e.streamId, e.seq, e.wallAt))
@@ -153,6 +153,14 @@ class HyperP2PMediaChunker extends EventEmitter {
return this.snapshot().stored return this.snapshot().stored
} }
listKeys () {
return [...this._chunks.keys()]
}
keyCount () {
return this.size()
}
getStats () { getStats () {
return mediaStats(this._stats, PROTOCOL, { stored: this._chunks.size }) return mediaStats(this._stats, PROTOCOL, { stored: this._chunks.size })
} }
@@ -188,6 +188,14 @@ class HyperP2PMediaTreeOrchestrator extends EventEmitter {
return this.snapshot().nodes return this.snapshot().nodes
} }
listKeys () {
return this.peerIds()
}
keyCount () {
return this.size()
}
_gossip (payload) { _gossip (payload) {
if (!this._peerMsgs) return if (!this._peerMsgs) return
gossipSend(this, payload) gossipSend(this, payload)
@@ -124,6 +124,14 @@ class HyperP2POriginHybridBridge extends EventEmitter {
return this.snapshot().streams return this.snapshot().streams
} }
listKeys () {
return this.listStreamIds()
}
keyCount () {
return this.size()
}
registerOriginBatch (entries) { registerOriginBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.registerOrigin(e.streamId, e.url, e.weight)) return entries.map((e) => this.registerOrigin(e.streamId, e.url, e.weight))
@@ -146,6 +146,14 @@ class HyperP2PPeerSelectorStreaming extends EventEmitter {
return this.snapshot().peers return this.snapshot().peers
} }
listKeys () {
return this.peerIds()
}
keyCount () {
return this.size()
}
registerPeerBatch (entries) { registerPeerBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.registerPeer(e.peerId, e.stats || {})) return entries.map((e) => this.registerPeer(e.peerId, e.stats || {}))
@@ -126,6 +126,14 @@ class HyperP2PQualityLadder extends EventEmitter {
return this.snapshot().ladders return this.snapshot().ladders
} }
listKeys () {
return this.listStreamIds()
}
keyCount () {
return this.size()
}
getStats () { getStats () {
return mediaStats(this._stats, PROTOCOL, { ladders: this._ladders.size }) return mediaStats(this._stats, PROTOCOL, { ladders: this._ladders.size })
} }
@@ -132,6 +132,14 @@ class HyperP2PStreamAccessControl extends EventEmitter {
return this.snapshot().total return this.snapshot().total
} }
listKeys () {
return [...this._tokens.keys()]
}
keyCount () {
return this.size()
}
grantCapabilityBatch (entries) { grantCapabilityBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.grantCapability(e.streamId, e.subject, e.ttlMs)) return entries.map((e) => this.grantCapability(e.streamId, e.subject, e.ttlMs))
@@ -129,6 +129,14 @@ class HyperP2PStreamManifest extends EventEmitter {
return this.snapshot().count return this.snapshot().count
} }
listKeys () {
return this.listStreamIds()
}
keyCount () {
return this.size()
}
buildManifestBatch (entries) { buildManifestBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.buildManifest(e.streamId, e.meta || {})) return entries.map((e) => this.buildManifest(e.streamId, e.meta || {}))
@@ -148,6 +148,14 @@ class HyperP2PStreamTelemetry extends EventEmitter {
return this.sessionCount() return this.sessionCount()
} }
listKeys () {
return this.listSessionIds()
}
keyCount () {
return this.size()
}
getStats () { getStats () {
return mediaStats(this._stats, PROTOCOL, { sessions: this._sessions.size }) return mediaStats(this._stats, PROTOCOL, { sessions: this._sessions.size })
} }
@@ -171,6 +171,14 @@ class HyperP2PDedupFilter extends EventEmitter {
return this.snapshot().size === 0 return this.snapshot().size === 0
} }
listKeys () {
return [...this._seen]
}
keyCount () {
return this.size()
}
restoreSnapshot (snap) { restoreSnapshot (snap) {
if (!snap || !Array.isArray(snap.ids)) throw new Error('invalid snapshot') if (!snap || !Array.isArray(snap.ids)) throw new Error('invalid snapshot')
this._seen = new Set(snap.ids) this._seen = new Set(snap.ids)
@@ -404,6 +404,14 @@ class HyperP2PDistributedEventBus extends EventEmitter {
return s.topics + s.subscribers + this.seenEvents.size return s.topics + s.subscribers + this.seenEvents.size
} }
listKeys () {
return this.listTopics()
}
keyCount () {
return this.size()
}
hasSeen (eventId) { hasSeen (eventId) {
return this.seenEvents.has(String(eventId)) return this.seenEvents.has(String(eventId))
} }
@@ -170,6 +170,14 @@ class HyperP2PGossipMesh extends EventEmitter {
return this.seenCount() return this.seenCount()
} }
listKeys () {
return [...this._seen]
}
keyCount () {
return this.size()
}
hasSeen (id) { hasSeen (id) {
return this._seen.has(String(id)) return this._seen.has(String(id))
} }
@@ -149,6 +149,14 @@ class HyperP2PQosTopic extends EventEmitter {
return s.channels.length + s.handlers + depth return s.channels.length + s.handlers + depth
} }
listKeys () {
return this.listChannels()
}
keyCount () {
return this.size()
}
_onGossip (data) { _onGossip (data) {
if (!data || data.type !== 'qos-publish') return if (!data || data.type !== 'qos-publish') return
this._stats.gossipIn++ this._stats.gossipIn++
@@ -117,6 +117,14 @@ class HyperP2PRetainedMessages extends EventEmitter {
return this.snapshot().total return this.snapshot().total
} }
listKeys () {
return this.listChannels()
}
keyCount () {
return this.size()
}
retainBatch (entries) { retainBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.retain(e.channel, e.payload, e.opts || {})) return entries.map((e) => this.retain(e.channel, e.payload, e.opts || {}))
@@ -165,6 +165,14 @@ class HyperP2PSubscriptionLease extends EventEmitter {
return this.snapshot().leases return this.snapshot().leases
} }
listKeys () {
return this.listChannels()
}
keyCount () {
return this.size()
}
acquireBatch (channels) { acquireBatch (channels) {
if (!Array.isArray(channels)) throw new Error('channels array required') if (!Array.isArray(channels)) throw new Error('channels array required')
return channels.map((ch) => this.acquire(ch)) return channels.map((ch) => this.acquire(ch))
@@ -138,6 +138,14 @@ class HyperP2PTopicChannel extends EventEmitter {
return s.channels + s.retained return s.channels + s.retained
} }
listKeys () {
return this.listChannels()
}
keyCount () {
return this.size()
}
_deliverLocal (channel, payload, meta) { _deliverLocal (channel, payload, meta) {
const handler = this._subs.get(channel) const handler = this._subs.get(channel)
if (handler) { if (handler) {
@@ -147,6 +147,14 @@ class HyperP2PStreamMultiplex extends EventEmitter {
return this.snapshot().open return this.snapshot().open
} }
listKeys () {
return this.listOpenStreamIds()
}
keyCount () {
return this.size()
}
openStreamBatch (ids) { openStreamBatch (ids) {
if (!Array.isArray(ids)) throw new Error('ids array required') if (!Array.isArray(ids)) throw new Error('ids array required')
return ids.map((id) => this.openStream(id)) return ids.map((id) => this.openStream(id))
@@ -140,6 +140,14 @@ class HyperP2PStreamResumeToken extends EventEmitter {
return this.snapshot().tokens return this.snapshot().tokens
} }
listKeys () {
return [...this._tokens.keys()]
}
keyCount () {
return this.size()
}
writeBatch (chunks) { writeBatch (chunks) {
if (!Array.isArray(chunks)) throw new Error('chunks array required') if (!Array.isArray(chunks)) throw new Error('chunks array required')
return chunks.map((c) => this.write(c)) return chunks.map((c) => this.write(c))
@@ -115,6 +115,14 @@ class HyperP2PStreamTee extends EventEmitter {
return this.snapshot().branches return this.snapshot().branches
} }
listKeys () {
return this.listBranches()
}
keyCount () {
return this.size()
}
addBranchBatch (names) { addBranchBatch (names) {
if (!Array.isArray(names)) throw new Error('names array required') if (!Array.isArray(names)) throw new Error('names array required')
return names.map((name) => this.addBranch(name)) return names.map((name) => this.addBranch(name))
@@ -91,6 +91,14 @@ class HyperP2PCapabilityDiscovery extends EventEmitter {
return this.snapshot().capabilities return this.snapshot().capabilities
} }
listKeys () {
return this.listCapabilities()
}
keyCount () {
return this.size()
}
registerCapabilityBatch (entries) { registerCapabilityBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.registerCapability(e.name, e.meta || {})) return entries.map((e) => this.registerCapability(e.name, e.meta || {}))
@@ -107,6 +107,14 @@ class HyperP2PDiscoveryHealth extends EventEmitter {
return this.snapshot().peers return this.snapshot().peers
} }
listKeys () {
return [...this._peers.keys()]
}
keyCount () {
return this.size()
}
reportPeerBatch (entries) { reportPeerBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.reportPeer(e.peerId, e.status || {})) return entries.map((e) => this.reportPeer(e.peerId, e.status || {}))
@@ -97,6 +97,14 @@ class HyperP2PPeerBootstrapStore extends EventEmitter {
return this.snapshot().bootstraps return this.snapshot().bootstraps
} }
listKeys () {
return this.peerIds()
}
keyCount () {
return this.size()
}
_gossip (data) { _gossip (data) {
if (!this._peerMsgs) return if (!this._peerMsgs) return
gossipSend(this, data) gossipSend(this, data)
@@ -110,6 +110,14 @@ class HyperP2PSeederRegistry extends EventEmitter {
return this.snapshot().topics return this.snapshot().topics
} }
listKeys () {
return this.topicIds()
}
keyCount () {
return this.size()
}
_gossip (data) { _gossip (data) {
if (!this._peerMsgs) return if (!this._peerMsgs) return
gossipSend(this, data) gossipSend(this, data)
@@ -99,6 +99,14 @@ class HyperP2PTopicAnnouncer extends EventEmitter {
return this.snapshot().count return this.snapshot().count
} }
listKeys () {
return this.listTopicIds()
}
keyCount () {
return this.size()
}
_gossip (data) { _gossip (data) {
if (!this._peerMsgs) return if (!this._peerMsgs) return
gossipSend(this, data) gossipSend(this, data)
@@ -120,6 +120,14 @@ class HyperP2PAnycastSelector extends EventEmitter {
return s.tags + s.latencyPeers return s.tags + s.latencyPeers
} }
listKeys () {
return this.listTags()
}
keyCount () {
return this.size()
}
getStats () { getStats () {
return { ...this._stats, tags: this._tags.size, latencyPeers: this._latency.size, protocol: PROTOCOL } return { ...this._stats, tags: this._tags.size, latencyPeers: this._latency.size, protocol: PROTOCOL }
} }
@@ -108,6 +108,14 @@ class HyperP2PBandwidthBroker extends EventEmitter {
return this.snapshot().peers return this.snapshot().peers
} }
listKeys () {
return this.peerIds()
}
keyCount () {
return this.size()
}
grantBatch (entries) { grantBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.grant(e.peerId, e.bytes)) return entries.map((e) => this.grant(e.peerId, e.bytes))
@@ -135,6 +135,14 @@ class HyperP2PCircuitLoom extends EventEmitter {
return this.snapshot().total return this.snapshot().total
} }
listKeys () {
return this.listCircuitIds()
}
keyCount () {
return this.size()
}
hopCount (circuitId) { hopCount (circuitId) {
const c = this._circuits.get(circuitId) const c = this._circuits.get(circuitId)
return c ? c.hops.length : 0 return c ? c.hops.length : 0
@@ -104,6 +104,14 @@ class HyperP2PCongestionSignal extends EventEmitter {
return this.snapshot().peers return this.snapshot().peers
} }
listKeys () {
return this.listPeerIds()
}
keyCount () {
return this.size()
}
reportSampleBatch (entries) { reportSampleBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.reportSample(e.peerId, e.rttMs, e.loss)) return entries.map((e) => this.reportSample(e.peerId, e.rttMs, e.loss))
@@ -109,6 +109,14 @@ class HyperP2PConnectionPool extends EventEmitter {
return this.snapshot().total return this.snapshot().total
} }
listKeys () {
return this.listPeerIds()
}
keyCount () {
return this.size()
}
acquireBatch (peerIds) { acquireBatch (peerIds) {
if (!Array.isArray(peerIds)) throw new Error('peerIds array required') if (!Array.isArray(peerIds)) throw new Error('peerIds array required')
return peerIds.map((peerId) => this.acquire(peerId)) return peerIds.map((peerId) => this.acquire(peerId))
@@ -112,6 +112,14 @@ class HyperP2PLinkProbe extends EventEmitter {
return this.snapshot().entries return this.snapshot().entries
} }
listKeys () {
return this.listPeerIds()
}
keyCount () {
return this.size()
}
probeBatch (peerIds) { probeBatch (peerIds) {
if (!Array.isArray(peerIds)) throw new Error('peerIds array required') if (!Array.isArray(peerIds)) throw new Error('peerIds array required')
return peerIds.map((id) => this.probe(id)) return peerIds.map((id) => this.probe(id))
@@ -121,6 +121,14 @@ class HyperP2PMultipathFanout extends EventEmitter {
return this.pendingCount() return this.pendingCount()
} }
listKeys () {
return this.listPendingIds()
}
keyCount () {
return this.size()
}
fanoutBatch (entries) { fanoutBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.fanout(e.payload, e.pathCount)) return entries.map((e) => this.fanout(e.payload, e.pathCount))
@@ -108,6 +108,14 @@ class HyperP2POverlayTopology extends EventEmitter {
return this.snapshot().degree return this.snapshot().degree
} }
listKeys () {
return this.neighborIds()
}
keyCount () {
return this.size()
}
getStats () { getStats () {
return { ...this._stats, degree: this._neighbors.size, protocol: PROTOCOL } return { ...this._stats, degree: this._neighbors.size, protocol: PROTOCOL }
} }
@@ -113,6 +113,14 @@ class HyperP2PProtocolHandshake extends EventEmitter {
return s.pending + s.agreed return s.pending + s.agreed
} }
listKeys () {
return [...this._offers.keys(), ...this._agreed.keys()]
}
keyCount () {
return this.size()
}
offerBatch (entries) { offerBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.offer(e.features || {})) return entries.map((e) => this.offer(e.features || {}))
@@ -136,6 +136,14 @@ class HyperP2PBlindRelayBridge extends EventEmitter {
return this.snapshot().relays return this.snapshot().relays
} }
listKeys () {
return [...this._relays.keys()]
}
keyCount () {
return this.size()
}
registerRelayBatch (entries) { registerRelayBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.registerRelay(e.peerId, e.endpoint)) return entries.map((e) => this.registerRelay(e.peerId, e.endpoint))
@@ -131,6 +131,14 @@ class HyperP2PDhtBootstrapHint extends EventEmitter {
return this.snapshot().hints return this.snapshot().hints
} }
listKeys () {
return [...this._hints.keys()]
}
keyCount () {
return this.size()
}
addHintBatch (entries) { addHintBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.addHint(e.nodeId, e.address)) return entries.map((e) => this.addHint(e.nodeId, e.address))
@@ -125,6 +125,14 @@ class HyperP2PNoiseSessionWrap extends EventEmitter {
return this.snapshot().total return this.snapshot().total
} }
listKeys () {
return [...this._sessions.keys()]
}
keyCount () {
return this.size()
}
createSessionBatch (optsList) { createSessionBatch (optsList) {
if (!Array.isArray(optsList)) throw new Error('optsList array required') if (!Array.isArray(optsList)) throw new Error('optsList array required')
return optsList.map((opts) => this.createSession(opts)) return optsList.map((opts) => this.createSession(opts))
@@ -144,6 +144,14 @@ class HyperP2PWakeupChannel extends EventEmitter {
return this.snapshot().pending return this.snapshot().pending
} }
listKeys () {
return this.pendingPeerIds()
}
keyCount () {
return this.size()
}
getStats () { getStats () {
return { return {
...this._stats, ...this._stats,
@@ -112,6 +112,14 @@ class HyperP2PHealthProbe extends EventEmitter {
return this.snapshot().peers return this.snapshot().peers
} }
listKeys () {
return this.peerIds()
}
keyCount () {
return this.size()
}
getStats () { getStats () {
return { return {
...this._stats, ...this._stats,
@@ -77,6 +77,14 @@ class HyperP2PStatsExporter extends EventEmitter {
return this._sources.size + this._history.length return this._sources.size + this._history.length
} }
listKeys () {
return this.listSources()
}
keyCount () {
return this.size()
}
exportSnapshot (filter = null) { exportSnapshot (filter = null) {
return this.moduleSnapshot(filter) return this.moduleSnapshot(filter)
} }
@@ -126,6 +126,14 @@ class HyperP2PTraceSpan extends EventEmitter {
return this.snapshot().total return this.snapshot().total
} }
listKeys () {
return this.listSpanIds()
}
keyCount () {
return this.size()
}
startSpanBatch (entries) { startSpanBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.startSpan(e.name, e.parentId ?? null)) return entries.map((e) => this.startSpan(e.name, e.parentId ?? null))
@@ -510,6 +510,14 @@ class HyperP2PDecentralizedOracle extends EventEmitter {
return s.feeds.length + s.pendingReports return s.feeds.length + s.pendingReports
} }
listKeys () {
return this.listFeeds()
}
keyCount () {
return this.size()
}
getStats () { getStats () {
return { return {
...this._stats, ...this._stats,
@@ -176,6 +176,14 @@ class HyperP2PCircuitBreaker extends EventEmitter {
return this.snapshot().registered return this.snapshot().registered
} }
listKeys () {
return this.listCircuitIds()
}
keyCount () {
return this.size()
}
getStats () { getStats () {
return { return {
...this._stats, ...this._stats,
@@ -117,6 +117,14 @@ class HyperP2PGeoHintRouter extends EventEmitter {
return this.snapshot().peers return this.snapshot().peers
} }
listKeys () {
return this.peerIds()
}
keyCount () {
return this.size()
}
getStats () { getStats () {
return { ...this._stats, registered: this._peers.size, protocol: PROTOCOL } return { ...this._stats, registered: this._peers.size, protocol: PROTOCOL }
} }
@@ -115,6 +115,14 @@ class HyperP2PLoadSpread extends EventEmitter {
return this.snapshot().peers return this.snapshot().peers
} }
listKeys () {
return this.peerIds()
}
keyCount () {
return this.size()
}
registerPeerBatch (entries) { registerPeerBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
for (const e of entries) this.registerPeer(e.peerId, e.load) for (const e of entries) this.registerPeer(e.peerId, e.load)
@@ -115,6 +115,14 @@ class HyperP2PRetryPolicy extends EventEmitter {
return this.snapshot().routes return this.snapshot().routes
} }
listKeys () {
return this.listRoutes()
}
keyCount () {
return this.size()
}
resetStats () { resetStats () {
this._stats = { routes: this._routes.size, retries: 0, denied: 0 } this._stats = { routes: this._routes.size, retries: 0, denied: 0 }
return this._stats return this._stats
@@ -97,6 +97,14 @@ class HyperP2PStickySession extends EventEmitter {
return this.snapshot().count return this.snapshot().count
} }
listKeys () {
return this.listSessions()
}
keyCount () {
return this.size()
}
_onGossip (d) { _onGossip (d) {
if (!d || d.type !== 'sticky-session-sync' || !d.sessionId) return if (!d || d.type !== 'sticky-session-sync' || !d.sessionId) return
this._stats.gossipIn++ this._stats.gossipIn++
@@ -472,6 +472,14 @@ class HyperP2PIntentRouter extends EventEmitter {
return s.local + s.peerIntents return s.local + s.peerIntents
} }
listKeys () {
return [...this.localIntents.keys(), ...this.peerIntents.keys()]
}
keyCount () {
return this.size()
}
getPeerIntents (peerHex = null) { getPeerIntents (peerHex = null) {
if (peerHex) { if (peerHex) {
const p = this.peerIntents.get(peerHex) const p = this.peerIntents.get(peerHex)
@@ -178,6 +178,10 @@ class HyperP2PMergeRegistry extends EventEmitter {
return this.snapshot().count return this.snapshot().count
} }
keyCount () {
return this.entryCount()
}
registerBatch (entries) { registerBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.register(e.key, e.value, e.opts || {})) return entries.map((e) => this.register(e.key, e.value, e.opts || {}))
@@ -133,6 +133,14 @@ class HyperP2PPatternRouter extends EventEmitter {
return this.snapshot().routes return this.snapshot().routes
} }
listKeys () {
return this.listPatterns()
}
keyCount () {
return this.size()
}
async ready () { async ready () {
if (this.swarm || !this.topic) return this if (this.swarm || !this.topic) return this
await initModuleSwarm(this, { await initModuleSwarm(this, {
@@ -135,6 +135,14 @@ class HyperP2PRelayTunnel extends EventEmitter {
return this.snapshot().tunnels return this.snapshot().tunnels
} }
listKeys () {
return this.listRoutes()
}
keyCount () {
return this.size()
}
relayBatch (frames) { relayBatch (frames) {
if (!Array.isArray(frames)) throw new Error('frames array required') if (!Array.isArray(frames)) throw new Error('frames array required')
return frames.map((f) => this.relay(f.tunnelId, f.payload)) return frames.map((f) => this.relay(f.tunnelId, f.payload))
@@ -238,6 +238,17 @@ class HyperP2PActivityQueue extends EventEmitter {
return s.pending + s.claimed + s.deadLetter return s.pending + s.claimed + s.deadLetter
} }
listKeys () {
const ids = this._queue.map((e) => e.id)
for (const id of this._claimed.keys()) ids.push(id)
for (const e of this._deadLetter) ids.push(e.id)
return ids
}
keyCount () {
return this.size()
}
clearAll () { clearAll () {
const pending = this._queue.length const pending = this._queue.length
const claimed = this._claimed.size const claimed = this._claimed.size
@@ -132,6 +132,14 @@ class HyperP2PCronGossip extends EventEmitter {
return this.snapshot().jobs return this.snapshot().jobs
} }
listKeys () {
return [...this._jobs.keys()]
}
keyCount () {
return this.size()
}
scheduleBatch (entries) { scheduleBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
return entries.map((e) => this.schedule(e.expr, e.jobId)) return entries.map((e) => this.schedule(e.expr, e.jobId))
@@ -123,6 +123,14 @@ class HyperP2PDeadlineQueue extends EventEmitter {
return this.snapshot().pending return this.snapshot().pending
} }
listKeys () {
return [...this._byId.keys()]
}
keyCount () {
return this.size()
}
enqueueBatch (entries) { enqueueBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries array required') if (!Array.isArray(entries)) throw new Error('entries array required')
for (const e of entries) this.enqueue(e.id, e.task, e.deadline) for (const e of entries) this.enqueue(e.id, e.task, e.deadline)
@@ -102,6 +102,14 @@ class HyperP2PPeerScheduler extends EventEmitter {
return this.snapshot().jobs return this.snapshot().jobs
} }
listKeys () {
return [...this._jobs.keys()]
}
keyCount () {
return this.size()
}
scheduleBatch (entries) { scheduleBatch (entries) {
if (!Array.isArray(entries)) throw new Error('entries must be an array') if (!Array.isArray(entries)) throw new Error('entries must be an array')
return entries.map((e) => this.schedule(e.expr, e.id, { shard: e.shard })) return entries.map((e) => this.schedule(e.expr, e.id, { shard: e.shard }))

Some files were not shown because too many files have changed in this diff Show More