Expand consensus, agents, indexes, economy, pear, and observability modules
Add raft clearLog and logEntryAt, workflow nodeIds and failAllPending, runtime session endAllActive, message envelope resetStats, trie removeBatch, fulltext and marketplace clear helpers, credit accountCount, trace span bulk end, link probe clearAll, import map clearAll, grow-only set clearAll, and geo router peer listing utilities. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -176,6 +176,18 @@ class HyperP2PWorkflowGraph extends EventEmitter {
|
|||||||
return nodes
|
return nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nodeIds () {
|
||||||
|
return [...this._nodes.keys()]
|
||||||
|
}
|
||||||
|
|
||||||
|
failAllPending (reason = 'bulk-fail') {
|
||||||
|
let n = 0
|
||||||
|
for (const node of this._nodes.values()) {
|
||||||
|
if (node.state === 'pending' && this.fail(node.id, reason)) n++
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
merge (remote) {
|
merge (remote) {
|
||||||
if (!remote) return 0
|
if (!remote) return 0
|
||||||
let n = 0
|
let n = 0
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ class HyperP2PCreditLedger extends EventEmitter {
|
|||||||
|
|
||||||
listAccounts () { return [...this._accounts.keys()] }
|
listAccounts () { return [...this._accounts.keys()] }
|
||||||
|
|
||||||
|
accountCount () {
|
||||||
|
return this._accounts.size
|
||||||
|
}
|
||||||
|
|
||||||
hasAccount (accountId) { return this._accounts.has(accountId) }
|
hasAccount (accountId) { return this._accounts.has(accountId) }
|
||||||
|
|
||||||
totalSupply () {
|
totalSupply () {
|
||||||
|
|||||||
@@ -107,6 +107,18 @@ class HyperP2PMarketplaceListing extends EventEmitter {
|
|||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearAll () {
|
||||||
|
const n = this._listings.size
|
||||||
|
this._listings.clear()
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
removeAllActive () {
|
||||||
|
const ids = this.listActive().map((l) => l.id)
|
||||||
|
for (const id of ids) this.removeListing(id)
|
||||||
|
return ids.length
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (payload) {
|
_gossip (payload) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, payload)
|
gossipSend(this, payload)
|
||||||
|
|||||||
@@ -60,6 +60,14 @@ class HyperP2PRaftLite extends EventEmitter {
|
|||||||
return removed
|
return removed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearLog () {
|
||||||
|
return this.truncateLog(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
logEntryAt (index) {
|
||||||
|
return this._log[index] || null
|
||||||
|
}
|
||||||
|
|
||||||
currentTerm () {
|
currentTerm () {
|
||||||
return this._currentTerm
|
return this._currentTerm
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,11 @@ class HyperP2PMessageEnvelope extends EventEmitter {
|
|||||||
return { ...envelope, payload, at: envelope.at || Date.now() }
|
return { ...envelope, payload, at: envelope.at || Date.now() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetStats () {
|
||||||
|
this._stats = { wrapped: 0, unwrapped: 0, encoded: 0, decoded: 0, failed: 0 }
|
||||||
|
return this._stats
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return { ...this._stats, protocol: PROTOCOL }
|
return { ...this._stats, protocol: PROTOCOL }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,6 +141,17 @@ class HyperP2PFulltextLite extends EventEmitter {
|
|||||||
.slice(0, limit)
|
.slice(0, limit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
documentIds () {
|
||||||
|
return [...this._docs.keys()]
|
||||||
|
}
|
||||||
|
|
||||||
|
clearAll () {
|
||||||
|
const n = this._docs.size
|
||||||
|
this._docs.clear()
|
||||||
|
this._index.clear()
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return {
|
return {
|
||||||
...this._stats,
|
...this._stats,
|
||||||
|
|||||||
@@ -101,6 +101,13 @@ class HyperP2PTriePrefix extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeBatch (words) {
|
||||||
|
if (!Array.isArray(words)) throw new Error('words array required')
|
||||||
|
let n = 0
|
||||||
|
for (const w of words) if (this.remove(w)) n++
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
longestMatch (prefix) {
|
longestMatch (prefix) {
|
||||||
const matches = this.prefixSearch(prefix)
|
const matches = this.prefixSearch(prefix)
|
||||||
if (!matches.length) return null
|
if (!matches.length) return null
|
||||||
|
|||||||
@@ -82,6 +82,12 @@ class HyperP2PLinkProbe extends EventEmitter {
|
|||||||
return this._metrics.delete(peerId)
|
return this._metrics.delete(peerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearAll () {
|
||||||
|
const n = this._metrics.size
|
||||||
|
this._metrics.clear()
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
publishMatrix () {
|
publishMatrix () {
|
||||||
const matrix = [...this._metrics.values()]
|
const matrix = [...this._metrics.values()]
|
||||||
if (this._peerMsgs) gossipSend(this, { type: 'matrix', matrix })
|
if (this._peerMsgs) gossipSend(this, { type: 'matrix', matrix })
|
||||||
|
|||||||
@@ -84,6 +84,20 @@ class HyperP2PTraceSpan extends EventEmitter {
|
|||||||
return roots.map(build)
|
return roots.map(build)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endAllActive () {
|
||||||
|
let n = 0
|
||||||
|
for (const span of this.activeSpans()) {
|
||||||
|
if (this.endSpan(span.id)) n++
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
clearAll () {
|
||||||
|
const n = this._spans.size
|
||||||
|
this._spans.clear()
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
_onGossip (data) {
|
_onGossip (data) {
|
||||||
if (!data || !data.type) return
|
if (!data || !data.type) return
|
||||||
this._stats.gossipIn++
|
this._stats.gossipIn++
|
||||||
|
|||||||
@@ -95,6 +95,12 @@ class HyperBareImportMap extends EventEmitter {
|
|||||||
return Object.keys(this._imports).length
|
return Object.keys(this._imports).length
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearAll () {
|
||||||
|
const n = Object.keys(this._imports).length
|
||||||
|
this._imports = {}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return platformStats(this._stats, PROTOCOL, { entries: Object.keys(this._imports).length })
|
return platformStats(this._stats, PROTOCOL, { entries: Object.keys(this._imports).length })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,6 +79,21 @@ class HyperPearRuntimeSession extends EventEmitter {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endAllActive () {
|
||||||
|
let n = 0
|
||||||
|
for (const s of this.activeSessions()) {
|
||||||
|
this.endSession(s.id)
|
||||||
|
n++
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
clearAll () {
|
||||||
|
const n = this._sessions.size
|
||||||
|
this._sessions.clear()
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
getStats () {
|
getStats () {
|
||||||
return {
|
return {
|
||||||
...this._stats,
|
...this._stats,
|
||||||
|
|||||||
@@ -72,6 +72,16 @@ class HyperP2PGeoHintRouter extends EventEmitter {
|
|||||||
return [...this._peers.entries()].map(([peerId, p]) => ({ peerId, ...p }))
|
return [...this._peers.entries()].map(([peerId, p]) => ({ peerId, ...p }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
peerIds () {
|
||||||
|
return [...this._peers.keys()]
|
||||||
|
}
|
||||||
|
|
||||||
|
clearAll () {
|
||||||
|
const n = this._peers.size
|
||||||
|
this._peers.clear()
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
_onGossip (d) {
|
_onGossip (d) {
|
||||||
if (!d || d.type !== 'geo-hint-sync' || !d.peerId) return
|
if (!d || d.type !== 'geo-hint-sync' || !d.peerId) return
|
||||||
this._stats.gossipIn++
|
this._stats.gossipIn++
|
||||||
|
|||||||
@@ -78,6 +78,12 @@ class HyperP2PCrdtGrowOnlySet extends EventEmitter {
|
|||||||
return this.values().filter((el) => other.has(el))
|
return this.values().filter((el) => other.has(el))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearAll () {
|
||||||
|
const n = this._added.size
|
||||||
|
this._added.clear()
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
_gossip (data) {
|
_gossip (data) {
|
||||||
if (!this._peerMsgs) return
|
if (!this._peerMsgs) return
|
||||||
gossipSend(this, data)
|
gossipSend(this, data)
|
||||||
|
|||||||
Reference in New Issue
Block a user