Add size() cardinality helper across modules (eighth pass).
Standardize a size() method after isEmpty() on every module with clearAll(), delegating to domain counts or snapshot fields so callers can query occupancy without parsing snapshots. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -466,6 +466,10 @@ class HyperP2PAgentMemory extends EventEmitter {
|
|||||||
return this.memoryCount() === 0
|
return this.memoryCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.memoryCount()
|
||||||
|
}
|
||||||
|
|
||||||
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 = []
|
||||||
|
|||||||
@@ -471,6 +471,10 @@ class HyperP2PTaskOrchestrator extends EventEmitter {
|
|||||||
return this.tasks.size === 0
|
return this.tasks.size === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.tasks.size
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
const counts = this.taskCounts()
|
const counts = this.taskCounts()
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -201,6 +201,10 @@ class HyperP2PWorkflowGraph extends EventEmitter {
|
|||||||
return this.nodeCount() === 0
|
return this.nodeCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.nodeCount()
|
||||||
|
}
|
||||||
|
|
||||||
nodeIds () {
|
nodeIds () {
|
||||||
return [...this._nodes.keys()]
|
return [...this._nodes.keys()]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,6 +180,10 @@ class HyperP2PCollabRoom extends EventEmitter {
|
|||||||
return this.roomCount() === 0
|
return this.roomCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.roomCount()
|
||||||
|
}
|
||||||
|
|
||||||
_onGossip (data) {
|
_onGossip (data) {
|
||||||
if (!data || !data.type) return
|
if (!data || !data.type) return
|
||||||
this._stats.gossipIn++
|
this._stats.gossipIn++
|
||||||
|
|||||||
@@ -126,6 +126,10 @@ class HyperP2PCursorPresence extends EventEmitter {
|
|||||||
return this.cursorCount() === 0
|
return this.cursorCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.cursorCount()
|
||||||
|
}
|
||||||
|
|
||||||
_onGossip (data) {
|
_onGossip (data) {
|
||||||
if (!data) return
|
if (!data) return
|
||||||
this._stats.gossipIn++
|
this._stats.gossipIn++
|
||||||
|
|||||||
@@ -120,6 +120,10 @@ class HyperP2PDocumentLineLock extends EventEmitter {
|
|||||||
return this.lockCount() === 0
|
return this.lockCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.lockCount()
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -118,6 +118,10 @@ class HyperP2PWhiteboardOp extends EventEmitter {
|
|||||||
return this.opCount() === 0
|
return this.opCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.opCount()
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -153,6 +153,10 @@ class HyperP2PAuctionGossip extends EventEmitter {
|
|||||||
return this.snapshot().auctions === 0
|
return this.snapshot().auctions === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().auctions
|
||||||
|
}
|
||||||
|
|
||||||
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 || {}))
|
||||||
|
|||||||
@@ -122,6 +122,10 @@ class HyperP2PCreditLedger extends EventEmitter {
|
|||||||
return this.accountCount() === 0
|
return this.accountCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.accountCount()
|
||||||
|
}
|
||||||
|
|
||||||
_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)
|
||||||
|
|||||||
@@ -133,6 +133,10 @@ class HyperP2PMarketplaceListing extends EventEmitter {
|
|||||||
return this.snapshot().listings === 0
|
return this.snapshot().listings === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().listings
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -449,6 +449,10 @@ class HyperP2PCausalConsensus extends EventEmitter {
|
|||||||
return this.proposals.size === 0 && this.decidedOrders.size === 0
|
return this.proposals.size === 0 && this.decidedOrders.size === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.proposals.size + this.decidedOrders.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 = []
|
||||||
|
|||||||
@@ -390,6 +390,10 @@ class HyperP2PDistributedLock extends EventEmitter {
|
|||||||
return this.lockCount() === 0
|
return this.lockCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.lockCount()
|
||||||
|
}
|
||||||
|
|
||||||
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 = []
|
||||||
|
|||||||
@@ -164,6 +164,10 @@ class HyperP2PLeaderLease extends EventEmitter {
|
|||||||
return !this._leader && this.followerCount() === 0
|
return !this._leader && this.followerCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.followerCount() + (this._leader ? 1 : 0)
|
||||||
|
}
|
||||||
|
|
||||||
_gossipSync () {
|
_gossipSync () {
|
||||||
gossipSend(this, {
|
gossipSend(this, {
|
||||||
type: 'leader-lease-sync',
|
type: 'leader-lease-sync',
|
||||||
|
|||||||
@@ -214,6 +214,10 @@ class HyperP2PQuorumPool extends EventEmitter {
|
|||||||
return this.proposalCount() === 0
|
return this.proposalCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.proposalCount()
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -103,6 +103,10 @@ class HyperP2PRaftLite extends EventEmitter {
|
|||||||
return this.snapshot().logLength === 0
|
return this.snapshot().logLength === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().logLength
|
||||||
|
}
|
||||||
|
|
||||||
logEntryAt (index) {
|
logEntryAt (index) {
|
||||||
return this._log[index] || null
|
return this._log[index] || null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,6 +284,11 @@ class CapabilityManager extends EventEmitter {
|
|||||||
return s.issued === 0 && s.received === 0 && s.revoked === 0
|
return s.issued === 0 && s.received === 0 && s.revoked === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
const s = this.snapshot()
|
||||||
|
return s.issued + s.received + s.revoked
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -368,6 +368,10 @@ class HyperP2PPresence extends EventEmitter {
|
|||||||
return this.peers.size <= 1
|
return this.peers.size <= 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return Math.max(0, this.peers.size - 1)
|
||||||
|
}
|
||||||
|
|
||||||
announceNow () {
|
announceNow () {
|
||||||
this._broadcastPresence()
|
this._broadcastPresence()
|
||||||
return this.getSelf()
|
return this.getSelf()
|
||||||
|
|||||||
@@ -164,6 +164,10 @@ class RPCServer extends EventEmitter {
|
|||||||
return this.connectionCount() === 0 && this.pendingCount() === 0
|
return this.connectionCount() === 0 && this.pendingCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.connectionCount() + this.pendingCount()
|
||||||
|
}
|
||||||
|
|
||||||
connectionCount () { return this.connections.size }
|
connectionCount () { return this.connections.size }
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
|
|||||||
@@ -101,6 +101,10 @@ class HyperP2PSessionBridge extends EventEmitter {
|
|||||||
return this.pairCount() === 0
|
return this.pairCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.pairCount()
|
||||||
|
}
|
||||||
|
|
||||||
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 = []
|
||||||
|
|||||||
@@ -361,6 +361,10 @@ class HyperP2PVectorClock extends EventEmitter {
|
|||||||
return this.peerCount() === 0
|
return this.peerCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.peerCount()
|
||||||
|
}
|
||||||
|
|
||||||
clearAll () {
|
clearAll () {
|
||||||
const n = this.clock.size
|
const n = this.clock.size
|
||||||
this.clock.clear()
|
this.clock.clear()
|
||||||
|
|||||||
@@ -102,6 +102,11 @@ class HyperP2PCompactCodecBridge extends EventEmitter {
|
|||||||
return s.encode === 0 && s.decode === 0 && s.frames === 0
|
return s.encode === 0 && s.decode === 0 && s.frames === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
const s = this._stats
|
||||||
|
return s.encode + s.decode + s.frames
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return {
|
return {
|
||||||
...this._stats,
|
...this._stats,
|
||||||
|
|||||||
@@ -134,6 +134,11 @@ class HyperP2PMessageEnvelope extends EventEmitter {
|
|||||||
return s.wrapped === 0 && s.unwrapped === 0 && s.encoded === 0 && s.decoded === 0 && s.failed === 0
|
return s.wrapped === 0 && s.unwrapped === 0 && s.encoded === 0 && s.decoded === 0 && s.failed === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
const s = this._stats
|
||||||
|
return s.wrapped + s.unwrapped + s.encoded + s.decoded + s.failed
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return { ...this._stats, protocol: PROTOCOL }
|
return { ...this._stats, protocol: PROTOCOL }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,6 +126,10 @@ class HyperP2PSchemaValidator extends EventEmitter {
|
|||||||
return this.listSchemas().length === 0
|
return this.listSchemas().length === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.listSchemas().length
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -162,6 +162,10 @@ class HyperP2PWireRegistry extends EventEmitter {
|
|||||||
return this._codecs.size === 0 && this._protocols.size === 0
|
return this._codecs.size === 0 && this._protocols.size === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this._codecs.size + this._protocols.size
|
||||||
|
}
|
||||||
|
|
||||||
clearAll () {
|
clearAll () {
|
||||||
const codecs = this.clearAllCodecs()
|
const codecs = this.clearAllCodecs()
|
||||||
const protocols = this.unregisterAllProtocols()
|
const protocols = this.unregisterAllProtocols()
|
||||||
|
|||||||
@@ -153,6 +153,10 @@ class HyperP2PContradictionGraph extends EventEmitter {
|
|||||||
return this._claims.length === 0
|
return this._claims.length === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this._claims.length
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -97,6 +97,10 @@ class HyperP2PEntropyBeacon extends EventEmitter {
|
|||||||
return this.snapshot().contributions === 0
|
return this.snapshot().contributions === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.contributionCount()
|
||||||
|
}
|
||||||
|
|
||||||
contributionCount () {
|
contributionCount () {
|
||||||
return this._contributions
|
return this._contributions
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,10 @@ class HyperP2PEntropySpiral extends EventEmitter {
|
|||||||
return this.snapshot().samples.length === 0
|
return this.snapshot().samples.length === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().samples.length
|
||||||
|
}
|
||||||
|
|
||||||
sampleBatch (seeds) {
|
sampleBatch (seeds) {
|
||||||
if (!Array.isArray(seeds)) throw new Error('seeds array required')
|
if (!Array.isArray(seeds)) throw new Error('seeds array required')
|
||||||
return seeds.map((seed) => this.sampleEntropy(seed))
|
return seeds.map((seed) => this.sampleEntropy(seed))
|
||||||
|
|||||||
@@ -132,6 +132,10 @@ class HyperP2PGravityWell extends EventEmitter {
|
|||||||
return this.snapshot().wells.length === 0
|
return this.snapshot().wells.length === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().wells.length
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -116,6 +116,10 @@ class HyperP2PMemeticSpread extends EventEmitter {
|
|||||||
return this.snapshot().totalMemes === 0
|
return this.snapshot().totalMemes === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().totalMemes
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (data) {
|
_gossip (data) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, data)
|
gossipSend(this, data)
|
||||||
|
|||||||
@@ -156,6 +156,11 @@ class HyperP2PMirrorRealm extends EventEmitter {
|
|||||||
return s.realmA.length === 0 && s.realmB.length === 0
|
return s.realmA.length === 0 && s.realmB.length === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
const s = this.snapshot()
|
||||||
|
return s.realmA.length + s.realmB.length
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -134,6 +134,10 @@ class HyperP2PMyceliumPool extends EventEmitter {
|
|||||||
return this.snapshot().balances.length === 0
|
return this.snapshot().balances.length === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().balances.length
|
||||||
|
}
|
||||||
|
|
||||||
donateBatch (entries) {
|
donateBatch (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.donate(e.peerId, e.credits))
|
return entries.map((e) => this.donate(e.peerId, e.credits))
|
||||||
|
|||||||
@@ -133,6 +133,10 @@ class HyperP2PParadoxClock extends EventEmitter {
|
|||||||
return this.snapshot().stamps.length === 0
|
return this.snapshot().stamps.length === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().stamps.length
|
||||||
|
}
|
||||||
|
|
||||||
stampBatch (eventIds, opts = {}) {
|
stampBatch (eventIds, opts = {}) {
|
||||||
if (!Array.isArray(eventIds)) throw new Error('eventIds array required')
|
if (!Array.isArray(eventIds)) throw new Error('eventIds array required')
|
||||||
return eventIds.map((id) => this.stamp(id, opts))
|
return eventIds.map((id) => this.stamp(id, opts))
|
||||||
|
|||||||
@@ -110,6 +110,11 @@ class HyperP2PParadoxMerge extends EventEmitter {
|
|||||||
return s.open === 0 && s.resolved === 0
|
return s.open === 0 && s.resolved === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
const s = this.snapshot()
|
||||||
|
return s.open + s.resolved
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -120,6 +120,10 @@ class HyperP2PPhaseShiftClock extends EventEmitter {
|
|||||||
return Object.keys(this.snapshot().peers).length === 0
|
return Object.keys(this.snapshot().peers).length === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return Object.keys(this.snapshot().peers).length
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -130,6 +130,10 @@ class HyperP2PPheromoneTrail extends EventEmitter {
|
|||||||
return this.trailCount() === 0
|
return this.trailCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.trailCount()
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -124,6 +124,10 @@ class HyperP2PSilenceProtocol extends EventEmitter {
|
|||||||
return this.listAbsent().length === 0
|
return this.listAbsent().length === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.listAbsent().length
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -169,6 +169,10 @@ class HyperP2PTensionField extends EventEmitter {
|
|||||||
return this.snapshot().cells === 0
|
return this.snapshot().cells === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().cells
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return experimentalStats(this._stats, PROTOCOL, {
|
return experimentalStats(this._stats, PROTOCOL, {
|
||||||
cells: this._field.size,
|
cells: this._field.size,
|
||||||
|
|||||||
@@ -168,6 +168,10 @@ class HyperP2PTimeCapsule extends EventEmitter {
|
|||||||
return this.snapshot().total === 0
|
return this.snapshot().total === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().total
|
||||||
|
}
|
||||||
|
|
||||||
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 || {}))
|
||||||
|
|||||||
@@ -96,6 +96,10 @@ class HyperP2PVoidChannel extends EventEmitter {
|
|||||||
return this.snapshot().voids.length === 0
|
return this.snapshot().voids.length === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().voids.length
|
||||||
|
}
|
||||||
|
|
||||||
unsubscribeAll () {
|
unsubscribeAll () {
|
||||||
const n = this._subs.size
|
const n = this._subs.size
|
||||||
this._subs.clear()
|
this._subs.clear()
|
||||||
|
|||||||
@@ -115,6 +115,10 @@ class HyperP2PWhisperMesh extends EventEmitter {
|
|||||||
return this.snapshot().seen === 0
|
return this.snapshot().seen === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().seen
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -169,6 +169,10 @@ class HyperP2PFulltextLite extends EventEmitter {
|
|||||||
return this.snapshot().documents === 0
|
return this.snapshot().documents === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().documents
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -167,6 +167,10 @@ class HyperP2PGraphIndex extends EventEmitter {
|
|||||||
return this.snapshot().edges.length === 0
|
return this.snapshot().edges.length === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().edges.length
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -146,6 +146,10 @@ class HyperP2PInvertedIndex extends EventEmitter {
|
|||||||
return this.snapshot().documents === 0
|
return this.snapshot().documents === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().documents
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -661,6 +661,11 @@ class HyperP2PSemanticVectorIndex extends EventEmitter {
|
|||||||
const s = await this.snapshot()
|
const s = await this.snapshot()
|
||||||
return s.vectorIds === 0
|
return s.vectorIds === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async size () {
|
||||||
|
const s = await this.snapshot()
|
||||||
|
return s.vectorIds
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = HyperP2PSemanticVectorIndex
|
module.exports = HyperP2PSemanticVectorIndex
|
||||||
|
|||||||
@@ -187,6 +187,11 @@ class HyperP2PSimilarityLsh extends EventEmitter {
|
|||||||
return s.vectors === 0 && s.buckets === 0
|
return s.vectors === 0 && s.buckets === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
const s = this.snapshot()
|
||||||
|
return s.vectors + s.buckets
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return {
|
return {
|
||||||
...this._stats,
|
...this._stats,
|
||||||
|
|||||||
@@ -145,6 +145,10 @@ class HyperP2PTriePrefix extends EventEmitter {
|
|||||||
return this.snapshot().words === 0
|
return this.snapshot().words === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().words
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return {
|
return {
|
||||||
...this._stats,
|
...this._stats,
|
||||||
|
|||||||
@@ -292,6 +292,11 @@ class SpatialIndex extends EventEmitter {
|
|||||||
return s.points === 0
|
return s.points === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async size () {
|
||||||
|
const s = await this.snapshot()
|
||||||
|
return s.points
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return {
|
return {
|
||||||
...this._stats,
|
...this._stats,
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ class HyperP2PBucketRateLimit extends EventEmitter {
|
|||||||
return Object.keys(this.snapshot().buckets).length === 0
|
return Object.keys(this.snapshot().buckets).length === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return Object.keys(this.snapshot().buckets).length
|
||||||
|
}
|
||||||
|
|
||||||
_bucketSnapshot () {
|
_bucketSnapshot () {
|
||||||
const out = {}
|
const out = {}
|
||||||
for (const [peerId, b] of this._buckets) {
|
for (const [peerId, b] of this._buckets) {
|
||||||
|
|||||||
@@ -104,6 +104,10 @@ class HyperP2PHistogramGossip extends EventEmitter {
|
|||||||
return this._metrics.size === 0
|
return this._metrics.size === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this._metrics.size
|
||||||
|
}
|
||||||
|
|
||||||
toJSON () {
|
toJSON () {
|
||||||
return this.moduleSnapshot()
|
return this.moduleSnapshot()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,6 +130,10 @@ class HyperP2PPercentileSketch extends EventEmitter {
|
|||||||
return this.snapshot().samples === 0
|
return this.snapshot().samples === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().samples
|
||||||
|
}
|
||||||
|
|
||||||
summarize () {
|
summarize () {
|
||||||
this._sort()
|
this._sort()
|
||||||
if (!this._sorted.length) return null
|
if (!this._sorted.length) return null
|
||||||
|
|||||||
@@ -123,6 +123,10 @@ class HyperP2PSlaBudget extends EventEmitter {
|
|||||||
return this.serviceCount() === 0
|
return this.serviceCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.serviceCount()
|
||||||
|
}
|
||||||
|
|
||||||
toJSON () {
|
toJSON () {
|
||||||
return this.moduleSnapshot()
|
return this.moduleSnapshot()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,6 +141,10 @@ class HyperP2PAdaptiveStreamingEngine extends EventEmitter {
|
|||||||
return this.snapshot().bufferMs === 0
|
return this.snapshot().bufferMs === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().bufferMs
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { recommendation: this._recommendation })
|
return mediaStats(this._stats, PROTOCOL, { recommendation: this._recommendation })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,6 +147,10 @@ class HyperP2PBandwidthAggregator extends EventEmitter {
|
|||||||
return this.sourceCount() === 0
|
return this.sourceCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.sourceCount()
|
||||||
|
}
|
||||||
|
|
||||||
sourceCount () {
|
sourceCount () {
|
||||||
return this._sources.size
|
return this._sources.size
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,6 +106,10 @@ class HyperP2PBufferHealthPredictor extends EventEmitter {
|
|||||||
return this.snapshot().samples === 0
|
return this.snapshot().samples === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.sampleCount()
|
||||||
|
}
|
||||||
|
|
||||||
sampleCount () {
|
sampleCount () {
|
||||||
return this._samples.length
|
return this._samples.length
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,6 +125,10 @@ class HyperP2PChunkSchedulerMedia extends EventEmitter {
|
|||||||
return this.snapshot().pending === 0
|
return this.snapshot().pending === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().pending
|
||||||
|
}
|
||||||
|
|
||||||
enqueueBatch (chunks) {
|
enqueueBatch (chunks) {
|
||||||
if (!Array.isArray(chunks)) throw new Error('chunks array required')
|
if (!Array.isArray(chunks)) throw new Error('chunks array required')
|
||||||
return chunks.map((chunk) => this.enqueue(chunk))
|
return chunks.map((chunk) => this.enqueue(chunk))
|
||||||
|
|||||||
@@ -125,6 +125,10 @@ class HyperP2PContentProtection extends EventEmitter {
|
|||||||
return this.snapshot().keys === 0
|
return this.snapshot().keys === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.keyCount()
|
||||||
|
}
|
||||||
|
|
||||||
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 })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,6 +114,10 @@ class HyperP2PContributionLedger extends EventEmitter {
|
|||||||
return this.snapshot().contributors === 0
|
return this.snapshot().contributors === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().contributors
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (payload) {
|
_gossip (payload) {
|
||||||
if (this._peerMsgs) {
|
if (this._peerMsgs) {
|
||||||
gossipSend(this, payload)
|
gossipSend(this, payload)
|
||||||
|
|||||||
@@ -134,6 +134,10 @@ class HyperP2PEnterpriseOrchestrator extends EventEmitter {
|
|||||||
return this.snapshot().count === 0
|
return this.snapshot().count === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().count
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { regions: this._regions.size })
|
return mediaStats(this._stats, PROTOCOL, { regions: this._regions.size })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,10 @@ class HyperP2PFecVideo extends EventEmitter {
|
|||||||
return this.snapshot().groups === 0
|
return this.snapshot().groups === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().groups
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { groups: this._groups.size })
|
return mediaStats(this._stats, PROTOCOL, { groups: this._groups.size })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,6 +133,10 @@ class HyperP2PHelperSwarmCoordinator extends EventEmitter {
|
|||||||
return this.snapshot().helpers === 0
|
return this.snapshot().helpers === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().helpers
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -111,6 +111,10 @@ class HyperP2PLatencyOptimizer extends EventEmitter {
|
|||||||
return this.snapshot().paths === 0
|
return this.snapshot().paths === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().paths
|
||||||
|
}
|
||||||
|
|
||||||
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 || []))
|
||||||
|
|||||||
@@ -112,6 +112,10 @@ class HyperP2PLiveEdgeManager extends EventEmitter {
|
|||||||
return this.snapshot().count === 0
|
return this.snapshot().count === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().count
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -149,6 +149,10 @@ class HyperP2PMediaChunker extends EventEmitter {
|
|||||||
return this.snapshot().stored === 0
|
return this.snapshot().stored === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().stored
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { stored: this._chunks.size })
|
return mediaStats(this._stats, PROTOCOL, { stored: this._chunks.size })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,6 +184,10 @@ class HyperP2PMediaTreeOrchestrator extends EventEmitter {
|
|||||||
return this.snapshot().nodes === 0
|
return this.snapshot().nodes === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().nodes
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (payload) {
|
_gossip (payload) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, payload)
|
gossipSend(this, payload)
|
||||||
|
|||||||
@@ -120,6 +120,10 @@ class HyperP2POriginHybridBridge extends EventEmitter {
|
|||||||
return this.snapshot().streams === 0
|
return this.snapshot().streams === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().streams
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -142,6 +142,10 @@ class HyperP2PPeerSelectorStreaming extends EventEmitter {
|
|||||||
return this.snapshot().peers === 0
|
return this.snapshot().peers === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().peers
|
||||||
|
}
|
||||||
|
|
||||||
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 || {}))
|
||||||
|
|||||||
@@ -122,6 +122,10 @@ class HyperP2PQualityLadder extends EventEmitter {
|
|||||||
return this.snapshot().ladders === 0
|
return this.snapshot().ladders === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().ladders
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { ladders: this._ladders.size })
|
return mediaStats(this._stats, PROTOCOL, { ladders: this._ladders.size })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,10 @@ class HyperP2PRetransmissionMedia extends EventEmitter {
|
|||||||
return this.snapshot().pending === 0
|
return this.snapshot().pending === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().pending
|
||||||
|
}
|
||||||
|
|
||||||
nackBatch (entries) {
|
nackBatch (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.nack(e.streamId, e.seq, e.reason))
|
return entries.map((e) => this.nack(e.streamId, e.seq, e.reason))
|
||||||
|
|||||||
@@ -128,6 +128,10 @@ class HyperP2PStreamAccessControl extends EventEmitter {
|
|||||||
return this.snapshot().total === 0
|
return this.snapshot().total === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().total
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -125,6 +125,10 @@ class HyperP2PStreamManifest extends EventEmitter {
|
|||||||
return this.snapshot().count === 0
|
return this.snapshot().count === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().count
|
||||||
|
}
|
||||||
|
|
||||||
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 || {}))
|
||||||
|
|||||||
@@ -144,6 +144,10 @@ class HyperP2PStreamTelemetry extends EventEmitter {
|
|||||||
return this.sessionCount() === 0
|
return this.sessionCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.sessionCount()
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return mediaStats(this._stats, PROTOCOL, { sessions: this._sessions.size })
|
return mediaStats(this._stats, PROTOCOL, { sessions: this._sessions.size })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -399,6 +399,11 @@ class HyperP2PDistributedEventBus extends EventEmitter {
|
|||||||
return s.topics === 0 && s.subscribers === 0 && this.seenEvents.size === 0
|
return s.topics === 0 && s.subscribers === 0 && this.seenEvents.size === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
const s = this.snapshot()
|
||||||
|
return s.topics + s.subscribers + this.seenEvents.size
|
||||||
|
}
|
||||||
|
|
||||||
hasSeen (eventId) {
|
hasSeen (eventId) {
|
||||||
return this.seenEvents.has(String(eventId))
|
return this.seenEvents.has(String(eventId))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,6 +166,10 @@ class HyperP2PGossipMesh extends EventEmitter {
|
|||||||
return this.seenCount() === 0
|
return this.seenCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.seenCount()
|
||||||
|
}
|
||||||
|
|
||||||
hasSeen (id) {
|
hasSeen (id) {
|
||||||
return this._seen.has(String(id))
|
return this._seen.has(String(id))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,6 +143,12 @@ class HyperP2PQosTopic extends EventEmitter {
|
|||||||
Object.values(s.queueDepths).every((n) => n === 0)
|
Object.values(s.queueDepths).every((n) => n === 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
const s = this.snapshot()
|
||||||
|
const depth = Object.values(s.queueDepths).reduce((a, n) => a + n, 0)
|
||||||
|
return s.channels.length + s.handlers + depth
|
||||||
|
}
|
||||||
|
|
||||||
_onGossip (data) {
|
_onGossip (data) {
|
||||||
if (!data || data.type !== 'qos-publish') return
|
if (!data || data.type !== 'qos-publish') return
|
||||||
this._stats.gossipIn++
|
this._stats.gossipIn++
|
||||||
|
|||||||
@@ -113,6 +113,10 @@ class HyperP2PRetainedMessages extends EventEmitter {
|
|||||||
return this.snapshot().total === 0
|
return this.snapshot().total === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().total
|
||||||
|
}
|
||||||
|
|
||||||
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 || {}))
|
||||||
|
|||||||
@@ -161,6 +161,10 @@ class HyperP2PSubscriptionLease extends EventEmitter {
|
|||||||
return this.snapshot().leases === 0
|
return this.snapshot().leases === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().leases
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -133,6 +133,11 @@ class HyperP2PTopicChannel extends EventEmitter {
|
|||||||
return s.channels === 0 && s.retained === 0
|
return s.channels === 0 && s.retained === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
const s = this.snapshot()
|
||||||
|
return s.channels + s.retained
|
||||||
|
}
|
||||||
|
|
||||||
_deliverLocal (channel, payload, meta) {
|
_deliverLocal (channel, payload, meta) {
|
||||||
const handler = this._subs.get(channel)
|
const handler = this._subs.get(channel)
|
||||||
if (handler) {
|
if (handler) {
|
||||||
|
|||||||
@@ -113,6 +113,10 @@ class HyperP2PStreamBackpressure extends EventEmitter {
|
|||||||
return s.bytes === 0 && !s.paused
|
return s.bytes === 0 && !s.paused
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().bytes
|
||||||
|
}
|
||||||
|
|
||||||
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((chunk) => this.write(chunk))
|
return chunks.map((chunk) => this.write(chunk))
|
||||||
|
|||||||
@@ -71,6 +71,10 @@ class HyperP2PStreamChunker extends EventEmitter {
|
|||||||
return this.snapshot().pending === 0
|
return this.snapshot().pending === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().pending
|
||||||
|
}
|
||||||
|
|
||||||
flush () {
|
flush () {
|
||||||
if (!this._pending.length) return null
|
if (!this._pending.length) return null
|
||||||
const tail = this._pending
|
const tail = this._pending
|
||||||
|
|||||||
@@ -143,6 +143,10 @@ class HyperP2PStreamMultiplex extends EventEmitter {
|
|||||||
return this.snapshot().open === 0
|
return this.snapshot().open === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().open
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -136,6 +136,10 @@ class HyperP2PStreamResumeToken extends EventEmitter {
|
|||||||
return this.snapshot().tokens === 0
|
return this.snapshot().tokens === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().tokens
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -111,6 +111,10 @@ class HyperP2PStreamTee extends EventEmitter {
|
|||||||
return this.snapshot().branches === 0
|
return this.snapshot().branches === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().branches
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -106,6 +106,10 @@ class HyperP2PStreamTransform extends EventEmitter {
|
|||||||
return this.snapshot().pending === 0
|
return this.snapshot().pending === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().pending
|
||||||
|
}
|
||||||
|
|
||||||
writeBatch (chunks) {
|
writeBatch (chunks) {
|
||||||
if (!Array.isArray(chunks)) throw new Error('chunks must be an array')
|
if (!Array.isArray(chunks)) throw new Error('chunks must be an array')
|
||||||
let ok = 0
|
let ok = 0
|
||||||
|
|||||||
@@ -87,6 +87,10 @@ class HyperP2PCapabilityDiscovery extends EventEmitter {
|
|||||||
return this.snapshot().capabilities === 0
|
return this.snapshot().capabilities === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().capabilities
|
||||||
|
}
|
||||||
|
|
||||||
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 || {}))
|
||||||
|
|||||||
@@ -103,6 +103,10 @@ class HyperP2PDiscoveryHealth extends EventEmitter {
|
|||||||
return this.snapshot().peers === 0
|
return this.snapshot().peers === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().peers
|
||||||
|
}
|
||||||
|
|
||||||
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 || {}))
|
||||||
|
|||||||
@@ -93,6 +93,10 @@ class HyperP2PPeerBootstrapStore extends EventEmitter {
|
|||||||
return this.snapshot().bootstraps === 0
|
return this.snapshot().bootstraps === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().bootstraps
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (data) {
|
_gossip (data) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, data)
|
gossipSend(this, data)
|
||||||
|
|||||||
@@ -106,6 +106,10 @@ class HyperP2PSeederRegistry extends EventEmitter {
|
|||||||
return this.snapshot().topics === 0
|
return this.snapshot().topics === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().topics
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (data) {
|
_gossip (data) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, data)
|
gossipSend(this, data)
|
||||||
|
|||||||
@@ -95,6 +95,10 @@ class HyperP2PTopicAnnouncer extends EventEmitter {
|
|||||||
return this.snapshot().count === 0
|
return this.snapshot().count === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().count
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (data) {
|
_gossip (data) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, data)
|
gossipSend(this, data)
|
||||||
|
|||||||
@@ -115,6 +115,11 @@ class HyperP2PAnycastSelector extends EventEmitter {
|
|||||||
return s.tags === 0 && s.latencyPeers === 0
|
return s.tags === 0 && s.latencyPeers === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
const s = this.snapshot()
|
||||||
|
return s.tags + s.latencyPeers
|
||||||
|
}
|
||||||
|
|
||||||
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 }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,6 +104,10 @@ class HyperP2PBandwidthBroker extends EventEmitter {
|
|||||||
return this.snapshot().peers === 0
|
return this.snapshot().peers === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().peers
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -131,6 +131,10 @@ class HyperP2PCircuitLoom extends EventEmitter {
|
|||||||
return this.snapshot().total === 0
|
return this.snapshot().total === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().total
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
@@ -100,6 +100,10 @@ class HyperP2PCongestionSignal extends EventEmitter {
|
|||||||
return this.snapshot().peers === 0
|
return this.snapshot().peers === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().peers
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -105,6 +105,10 @@ class HyperP2PConnectionPool extends EventEmitter {
|
|||||||
return this.snapshot().total === 0
|
return this.snapshot().total === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().total
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -125,6 +125,10 @@ class HyperP2PFlowShaper extends EventEmitter {
|
|||||||
return this.snapshot().queued === 0
|
return this.snapshot().queued === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().queued
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return {
|
return {
|
||||||
...this._stats,
|
...this._stats,
|
||||||
|
|||||||
@@ -108,6 +108,10 @@ class HyperP2PLinkProbe extends EventEmitter {
|
|||||||
return this.snapshot().entries === 0
|
return this.snapshot().entries === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().entries
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -117,6 +117,10 @@ class HyperP2PMultipathFanout extends EventEmitter {
|
|||||||
return this.pendingCount() === 0
|
return this.pendingCount() === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.pendingCount()
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -104,6 +104,10 @@ class HyperP2POverlayTopology extends EventEmitter {
|
|||||||
return this.snapshot().degree === 0
|
return this.snapshot().degree === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().degree
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return { ...this._stats, degree: this._neighbors.size, protocol: PROTOCOL }
|
return { ...this._stats, degree: this._neighbors.size, protocol: PROTOCOL }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,6 +108,11 @@ class HyperP2PProtocolHandshake extends EventEmitter {
|
|||||||
return s.pending === 0 && s.agreed === 0
|
return s.pending === 0 && s.agreed === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
const s = this.snapshot()
|
||||||
|
return s.pending + s.agreed
|
||||||
|
}
|
||||||
|
|
||||||
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 || {}))
|
||||||
|
|||||||
@@ -132,6 +132,10 @@ class HyperP2PBlindRelayBridge extends EventEmitter {
|
|||||||
return this.snapshot().relays === 0
|
return this.snapshot().relays === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().relays
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -127,6 +127,10 @@ class HyperP2PDhtBootstrapHint extends EventEmitter {
|
|||||||
return this.snapshot().hints === 0
|
return this.snapshot().hints === 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size () {
|
||||||
|
return this.snapshot().hints
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user