Enrich module APIs with snapshot and batch helpers across categories.
Adds snapshot(), domain batch methods, and clearAll aliases on consensus, core, encoding, experimental, indexes, messaging, network, oracle, pear, routing, storage, supercomputer, and trust modules. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -424,6 +424,15 @@ class HyperP2PCausalConsensus extends EventEmitter {
|
|||||||
return { proposals, decided }
|
return { proposals, decided }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return {
|
||||||
|
proposals: this.proposalIds().length,
|
||||||
|
decided: this.decidedOrders.size,
|
||||||
|
peers: this.peers.size,
|
||||||
|
metrics: this.getMetrics()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getMetrics () {
|
getMetrics () {
|
||||||
return { ...this._metrics, peers: this.peers.size, pendingProposals: this.proposals.size - this.decidedOrders.size }
|
return { ...this._metrics, peers: this.peers.size, pendingProposals: this.proposals.size - this.decidedOrders.size }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -366,6 +366,14 @@ class HyperP2PDistributedLock extends EventEmitter {
|
|||||||
return { released, locks }
|
return { released, locks }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return {
|
||||||
|
locks: this.locks.size,
|
||||||
|
owned: this.myLocks.size,
|
||||||
|
active: this.listActiveLocks().length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all currently active locks (local + remote).
|
* List all currently active locks (local + remote).
|
||||||
* Supports optional filter by owner or resource prefix.
|
* Supports optional filter by owner or resource prefix.
|
||||||
|
|||||||
@@ -139,6 +139,15 @@ class HyperP2PLeaderLease extends EventEmitter {
|
|||||||
return this.resetLease()
|
return this.resetLease()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return {
|
||||||
|
leader: this._leader,
|
||||||
|
term: this._term,
|
||||||
|
msRemaining: this.leaseRemainingMs(),
|
||||||
|
followers: this.followerCount()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_gossipSync () {
|
_gossipSync () {
|
||||||
gossipSend(this, {
|
gossipSend(this, {
|
||||||
type: 'leader-lease-sync',
|
type: 'leader-lease-sync',
|
||||||
|
|||||||
@@ -189,6 +189,20 @@ class HyperP2PQuorumPool extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return {
|
||||||
|
members: [...this._members],
|
||||||
|
proposals: this.proposalIds().length,
|
||||||
|
open: this.openProposals().length,
|
||||||
|
quorum: this.quorum
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
proposeBatch (payloads, opts = {}) {
|
||||||
|
if (!Array.isArray(payloads)) throw new Error('payloads array required')
|
||||||
|
return payloads.map((payload) => this.propose(payload, opts))
|
||||||
|
}
|
||||||
|
|
||||||
voteBatch (entries) {
|
voteBatch (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.vote(e.proposalId, e.voterId, e.accept !== false))
|
return entries.map((e) => this.vote(e.proposalId, e.voterId, e.accept !== false))
|
||||||
|
|||||||
@@ -78,6 +78,15 @@ class HyperP2PRaftLite extends EventEmitter {
|
|||||||
return entries.map((entry) => this.appendLog(entry))
|
return entries.map((entry) => this.appendLog(entry))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return {
|
||||||
|
term: this.currentTerm(),
|
||||||
|
role: this.role(),
|
||||||
|
logLength: this._log.length,
|
||||||
|
commitIndex: this._commitIndex
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logEntryAt (index) {
|
logEntryAt (index) {
|
||||||
return this._log[index] || null
|
return this._log[index] || null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,6 +259,19 @@ class CapabilityManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return {
|
||||||
|
issued: this.issued.size,
|
||||||
|
received: this.received.size,
|
||||||
|
revoked: this.revoked.size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
issueBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.issue(e.subjectPubKey, e.resource, e.actions, e.ttlMs))
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return {
|
return {
|
||||||
...this._stats,
|
...this._stats,
|
||||||
|
|||||||
@@ -348,6 +348,10 @@ class HyperP2PPresence extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { peers: this.peers.size, online: this.onlineCount(), ids: this.peerIds() }
|
||||||
|
}
|
||||||
|
|
||||||
announceNow () {
|
announceNow () {
|
||||||
this._broadcastPresence()
|
this._broadcastPresence()
|
||||||
return this.getSelf()
|
return this.getSelf()
|
||||||
|
|||||||
@@ -138,6 +138,10 @@ class RPCServer extends EventEmitter {
|
|||||||
return this.unregisterAll()
|
return this.unregisterAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { services: this.listServices(), connections: this.connectionCount() }
|
||||||
|
}
|
||||||
|
|
||||||
connectionCount () { return this.connections.size }
|
connectionCount () { return this.connections.size }
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
|
|||||||
@@ -345,6 +345,10 @@ class HyperP2PVectorClock extends EventEmitter {
|
|||||||
|
|
||||||
peerCount () { return this.clock.size }
|
peerCount () { return this.clock.size }
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { clock: this.toJSON(), peers: this.getKnownPeers(), local: this.getLocalCounter() }
|
||||||
|
}
|
||||||
|
|
||||||
clearAll () {
|
clearAll () {
|
||||||
const n = this.clock.size
|
const n = this.clock.size
|
||||||
this.clock.clear()
|
this.clock.clear()
|
||||||
|
|||||||
@@ -146,6 +146,17 @@ class HyperP2PWireRegistry extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearAll () {
|
||||||
|
const codecs = this.clearAllCodecs()
|
||||||
|
const protocols = this.unregisterAllProtocols()
|
||||||
|
return { codecs, protocols }
|
||||||
|
}
|
||||||
|
|
||||||
|
registerProtocolBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.registerProtocol(e.protocolId, e.meta || {}))
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return {
|
return {
|
||||||
...this._stats,
|
...this._stats,
|
||||||
|
|||||||
@@ -137,6 +137,10 @@ class HyperP2PContradictionGraph extends EventEmitter {
|
|||||||
return this._claims.length
|
return this._claims.length
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return this.toJSON()
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ class HyperP2PEntropySpiral extends EventEmitter {
|
|||||||
return this.reset()
|
return this.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return this.spiralState()
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -116,6 +116,10 @@ class HyperP2PGravityWell extends EventEmitter {
|
|||||||
return messages.map((msg) => this.attract(msg))
|
return messages.map((msg) => this.attract(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return this.toJSON()
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -96,6 +96,10 @@ class HyperP2PMemeticSpread extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return this.spreadStats()
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (data) {
|
_gossip (data) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, data)
|
gossipSend(this, data)
|
||||||
|
|||||||
@@ -139,6 +139,10 @@ class HyperP2PMirrorRealm extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return this.toJSON()
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -118,6 +118,15 @@ class HyperP2PMyceliumPool extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return this.toJSON()
|
||||||
|
}
|
||||||
|
|
||||||
|
donateBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.donate(e.peerId, e.credits))
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -117,6 +117,15 @@ class HyperP2PParadoxClock extends EventEmitter {
|
|||||||
return [...this._stamps.keys()]
|
return [...this._stamps.keys()]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return this.toJSON()
|
||||||
|
}
|
||||||
|
|
||||||
|
stampBatch (eventIds, opts = {}) {
|
||||||
|
if (!Array.isArray(eventIds)) throw new Error('eventIds array required')
|
||||||
|
return eventIds.map((id) => this.stamp(id, opts))
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ class HyperP2PParadoxMerge extends EventEmitter {
|
|||||||
return { branches, resolved }
|
return { branches, resolved }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { open: this.listOpen().length, resolved: this._resolved.size }
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (data) {
|
_gossip (data) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, data)
|
gossipSend(this, data)
|
||||||
|
|||||||
@@ -100,6 +100,10 @@ class HyperP2PPhaseShiftClock extends EventEmitter {
|
|||||||
return this.shift(deltaMs)
|
return this.shift(deltaMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { phaseMs: this._phaseMs, peers: this.peerPhases() }
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (data) {
|
_gossip (data) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, data)
|
gossipSend(this, data)
|
||||||
|
|||||||
@@ -114,6 +114,15 @@ class HyperP2PPheromoneTrail extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return this.toJSON()
|
||||||
|
}
|
||||||
|
|
||||||
|
depositBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.deposit(e.pathId, e.strength, e.dest))
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -108,6 +108,10 @@ class HyperP2PSilenceProtocol extends EventEmitter {
|
|||||||
return ids.length
|
return ids.length
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return this.toJSON()
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -149,6 +149,10 @@ class HyperP2PTensionField extends EventEmitter {
|
|||||||
return cells.map((c) => this.setField(c.x, c.y, c.value))
|
return cells.map((c) => this.setField(c.x, c.y, c.value))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { cells: this.cellCount(), energy: this.fieldEnergy(), peers: this._peerFields.size }
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return experimentalStats(this._stats, PROTOCOL, {
|
return experimentalStats(this._stats, PROTOCOL, {
|
||||||
cells: this._field.size,
|
cells: this._field.size,
|
||||||
|
|||||||
@@ -144,6 +144,14 @@ class HyperP2PTimeCapsule extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return {
|
||||||
|
sealed: this.listSealed().length,
|
||||||
|
ready: this.listReady().length,
|
||||||
|
total: this._capsules.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 || {}))
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ class HyperP2PVoidChannel extends EventEmitter {
|
|||||||
return { voids: [...this._voids.values()] }
|
return { voids: [...this._voids.values()] }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return this.toSnapshot()
|
||||||
|
}
|
||||||
|
|
||||||
unsubscribeAll () {
|
unsubscribeAll () {
|
||||||
const n = this._subs.size
|
const n = this._subs.size
|
||||||
this._subs.clear()
|
this._subs.clear()
|
||||||
|
|||||||
@@ -95,6 +95,10 @@ class HyperP2PWhisperMesh extends EventEmitter {
|
|||||||
return this.clearSeen()
|
return this.clearSeen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { seen: this._seen.size, maxHops: this.maxHops }
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -102,6 +102,15 @@ class HyperP2PBloomGossip extends EventEmitter {
|
|||||||
return this.clear()
|
return this.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { keys: this.listKeys(), fillRatio: this.fillRatio(), size: this._size }
|
||||||
|
}
|
||||||
|
|
||||||
|
addBatch (keys) {
|
||||||
|
if (!Array.isArray(keys)) throw new Error('keys array required')
|
||||||
|
return keys.map((k) => this.add(k))
|
||||||
|
}
|
||||||
|
|
||||||
union (payload) {
|
union (payload) {
|
||||||
if (!payload || !payload.bits) return 0
|
if (!payload || !payload.bits) return 0
|
||||||
const remote = b4a.from(payload.bits, 'hex')
|
const remote = b4a.from(payload.bits, 'hex')
|
||||||
|
|||||||
@@ -145,6 +145,19 @@ class HyperP2PFulltextLite extends EventEmitter {
|
|||||||
return [...this._docs.keys()]
|
return [...this._docs.keys()]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return {
|
||||||
|
documents: this.documentIds().length,
|
||||||
|
terms: this.termCount(),
|
||||||
|
topTerms: this.topTerms(8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
searchBatch (queries, mode = 'and') {
|
||||||
|
if (!Array.isArray(queries)) throw new Error('queries array required')
|
||||||
|
return queries.map((q) => this.search(q, mode))
|
||||||
|
}
|
||||||
|
|
||||||
clearAll () {
|
clearAll () {
|
||||||
const n = this._docs.size
|
const n = this._docs.size
|
||||||
this._docs.clear()
|
this._docs.clear()
|
||||||
|
|||||||
@@ -151,6 +151,15 @@ class HyperP2PGraphIndex extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return this.toJSON()
|
||||||
|
}
|
||||||
|
|
||||||
|
addEdgeBatch (edges) {
|
||||||
|
if (!Array.isArray(edges)) throw new Error('edges array required')
|
||||||
|
return edges.map((e) => this.addEdge(e.from, e.to))
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return {
|
return {
|
||||||
...this._stats,
|
...this._stats,
|
||||||
|
|||||||
@@ -126,6 +126,15 @@ class HyperP2PInvertedIndex extends EventEmitter {
|
|||||||
return docs
|
return docs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { terms: this.termCount(), documents: this._docs.size, topTerms: this.topTerms(8) }
|
||||||
|
}
|
||||||
|
|
||||||
|
indexBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.index(e.docId, e.terms))
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (data) {
|
_gossip (data) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, data)
|
gossipSend(this, data)
|
||||||
|
|||||||
@@ -125,6 +125,10 @@ class HyperP2PTriePrefix extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { words: this.wordCount(), sample: [...this._words].slice(0, 12) }
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return {
|
return {
|
||||||
...this._stats,
|
...this._stats,
|
||||||
|
|||||||
@@ -117,6 +117,14 @@ class HyperP2PQosTopic extends EventEmitter {
|
|||||||
return { handlers, pending }
|
return { handlers, pending }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return {
|
||||||
|
channels: this.listChannels(),
|
||||||
|
queueDepths: this.queueDepths(),
|
||||||
|
handlers: this.handlerCount()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_onGossip (data) {
|
_onGossip (data) {
|
||||||
if (!data || data.type !== 'qos-publish') return
|
if (!data || data.type !== 'qos-publish') return
|
||||||
this._stats.gossipIn++
|
this._stats.gossipIn++
|
||||||
|
|||||||
@@ -93,6 +93,15 @@ class HyperP2PRetainedMessages extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { channels: this.listChannels(), total: this.totalRetained() }
|
||||||
|
}
|
||||||
|
|
||||||
|
retainBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.retain(e.channel, e.payload, e.opts || {}))
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return {
|
return {
|
||||||
...this._stats,
|
...this._stats,
|
||||||
|
|||||||
@@ -66,6 +66,19 @@ class HyperP2PTopicAnnouncer extends EventEmitter {
|
|||||||
return ids.length
|
return ids.length
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearAll () {
|
||||||
|
return this.revokeAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
announceBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.announce(e.topicId, e.meta || {}))
|
||||||
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { topics: this.list(), count: this.topicCount() }
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (data) {
|
_gossip (data) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, data)
|
gossipSend(this, data)
|
||||||
|
|||||||
@@ -467,6 +467,27 @@ class HyperP2PDecentralizedOracle extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearAll () {
|
||||||
|
return this.clearAllFeeds()
|
||||||
|
}
|
||||||
|
|
||||||
|
async submitReportBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
const out = []
|
||||||
|
for (const e of entries) {
|
||||||
|
out.push(await this.submitReport(e.feedId, e.data, e.metadata || {}))
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return {
|
||||||
|
feeds: [...this.feeds.keys()],
|
||||||
|
pendingReports: this.pendingReports.size,
|
||||||
|
metrics: { ...this.metrics }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return {
|
return {
|
||||||
...this._stats,
|
...this._stats,
|
||||||
|
|||||||
@@ -77,6 +77,15 @@ class HyperBareBundleBridge extends EventEmitter {
|
|||||||
return this._bundles.size
|
return this._bundles.size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { bundles: this.listBundles(), count: this.bundleCount() }
|
||||||
|
}
|
||||||
|
|
||||||
|
registerBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.registerBundle(e.id, e.manifest))
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (data) {
|
_gossip (data) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, data)
|
gossipSend(this, data)
|
||||||
|
|||||||
@@ -67,8 +67,9 @@ class HyperBareDistributableHint extends EventEmitter {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
hasHint (appId) {
|
setHintBatch (entries) {
|
||||||
return this._hints.has(String(appId))
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.setHint(e.appId, e.layout))
|
||||||
}
|
}
|
||||||
|
|
||||||
clearAll () {
|
clearAll () {
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ class HyperP2PStickySession extends EventEmitter {
|
|||||||
return this._bindings.size
|
return this._bindings.size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { sessions: this.sessionIds(), count: this.bindingCount() }
|
||||||
|
}
|
||||||
|
|
||||||
_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++
|
||||||
|
|||||||
@@ -158,6 +158,15 @@ class HyperP2PMergeRegistry extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { keys: this.listKeys(), count: this.entryCount() }
|
||||||
|
}
|
||||||
|
|
||||||
|
registerBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.register(e.key, e.value, e.opts || {}))
|
||||||
|
}
|
||||||
|
|
||||||
tombstoneCount () {
|
tombstoneCount () {
|
||||||
return [...this._entries.values()].filter((e) => e.tombstone).length
|
return [...this._entries.values()].filter((e) => e.tombstone).length
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,10 @@ class HyperP2PPatternRouter extends EventEmitter {
|
|||||||
return this.clearRoutes()
|
return this.clearRoutes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { routes: this.routeCount(), patterns: this.listPatterns() }
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -111,6 +111,10 @@ class HyperP2PRelayTunnel extends EventEmitter {
|
|||||||
return { tunnels, routes }
|
return { tunnels, routes }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { tunnels: this.activeTunnelCount(), routes: this.routeCount() }
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
||||||
|
|||||||
@@ -77,6 +77,10 @@ class HyperP2PDriveEntryCatalog extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { entries: this.listEntries(), count: this._catalog.size }
|
||||||
|
}
|
||||||
|
|
||||||
mergeCatalog (entries) {
|
mergeCatalog (entries) {
|
||||||
const n = mergeCatalog(this._catalog, entries)
|
const n = mergeCatalog(this._catalog, entries)
|
||||||
if (n) this.emit('merge', { count: n })
|
if (n) this.emit('merge', { count: n })
|
||||||
|
|||||||
@@ -83,6 +83,15 @@ class HyperP2PDriveMountBridge extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mountPathBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.mountPath(e.localPrefix, e.remotePrefix))
|
||||||
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { mounts: this.listMounts(), count: this._mounts.size }
|
||||||
|
}
|
||||||
|
|
||||||
_onGossip (d) {
|
_onGossip (d) {
|
||||||
if (!d) return
|
if (!d) return
|
||||||
this._stats.gossipIn++
|
this._stats.gossipIn++
|
||||||
|
|||||||
@@ -118,6 +118,10 @@ class HyperP2PGpuSlot extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return this.clusterGpuSlots()
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -113,6 +113,15 @@ class HyperP2PThermalGuard extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { samples: this.listSamples(), health: this.clusterHealth() }
|
||||||
|
}
|
||||||
|
|
||||||
|
reportBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.reportLoad(e.peerId, e.cpuPct, e.ramPct, e.tempC))
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -98,6 +98,14 @@ class HyperP2PAttestationChain extends EventEmitter {
|
|||||||
return payloads.map((p) => this.append(p, opts))
|
return payloads.map((p) => this.append(p, opts))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return this.toJSON()
|
||||||
|
}
|
||||||
|
|
||||||
|
clearAll () {
|
||||||
|
return this.clearChain()
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
@@ -110,6 +110,10 @@ class HyperP2PBlindPairHandoff extends EventEmitter {
|
|||||||
return [...this._handoffs.keys()]
|
return [...this._handoffs.keys()]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { sessions: this.sessionIds(), count: this._handoffs.size }
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (data) {
|
_gossip (data) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, data)
|
gossipSend(this, data)
|
||||||
|
|||||||
@@ -104,6 +104,14 @@ class HyperP2PKeyRotation extends EventEmitter {
|
|||||||
return [...this._pending.keys()]
|
return [...this._pending.keys()]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return {
|
||||||
|
active: [...this._active.keys()],
|
||||||
|
pending: this.pendingKeyIds(),
|
||||||
|
count: this._active.size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_maybeActivate (keyId, now = Date.now()) {
|
_maybeActivate (keyId, now = Date.now()) {
|
||||||
const list = this._pending.get(keyId) || []
|
const list = this._pending.get(keyId) || []
|
||||||
for (const e of list) {
|
for (const e of list) {
|
||||||
|
|||||||
@@ -134,6 +134,18 @@ class HyperP2PMultisigThreshold extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return {
|
||||||
|
proposals: this.proposalIds().length,
|
||||||
|
pending: this.pendingProposals().length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
createProposalBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.createProposal(e.id, e.signers, e.threshold))
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (data) {
|
_gossip (data) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, data)
|
gossipSend(this, data)
|
||||||
|
|||||||
@@ -172,6 +172,15 @@ class HyperP2PTrustGraph extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshot () {
|
||||||
|
return { nodes: this.nodeCount(), edges: this.edges().length, decay: this.decay }
|
||||||
|
}
|
||||||
|
|
||||||
|
addEdgeBatch (entries) {
|
||||||
|
if (!Array.isArray(entries)) throw new Error('entries array required')
|
||||||
|
return entries.map((e) => this.addEdge(e.from, e.to, e.weight))
|
||||||
|
}
|
||||||
|
|
||||||
async ready () {
|
async ready () {
|
||||||
if (this.swarm || !this.topic) return this
|
if (this.swarm || !this.topic) return this
|
||||||
await initModuleSwarm(this, {
|
await initModuleSwarm(this, {
|
||||||
|
|||||||
Reference in New Issue
Block a user