Expand economy, autobase, network, observability, and scheduling modules.

Add auction withdraw/cancel, marketplace search helpers, update gossip history, autobase fork/lease/indexer/view APIs, link-probe and circuit-loom utilities, trace trees, pheromone ranking, and scheduling/measurement helpers with tests.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-21 01:09:29 -04:00
co-authored by Cursor
parent b8b815fce6
commit 44b8a80907
36 changed files with 508 additions and 4 deletions
@@ -55,6 +55,21 @@ class HyperP2PPeerScheduler extends EventEmitter {
return ok
}
nextDue (jobId) {
const job = this._jobs.get(jobId)
return job ? job.nextAt : null
}
dueJobs (now = Date.now()) {
return [...this._jobs.values()].filter((j) => now >= j.nextAt)
}
msUntil (jobId, now = Date.now()) {
const job = this._jobs.get(jobId)
if (!job) return null
return Math.max(0, job.nextAt - now)
}
_isLeader (shard) {
if (!this.topicLease) return true
const holder = this.topicLease.holder(shard)
@@ -13,6 +13,16 @@ test('peer-scheduler: schedule and manual tick', async (t) => {
await s.close()
})
test('peer-scheduler: nextDue dueJobs msUntil', async (t) => {
const s = new HyperP2PPeerScheduler()
const id = s.schedule(500, 'j')
const due = s.nextDue(id)
t.ok(due > Date.now())
t.is(s.dueJobs(due - 1).length, 0)
t.ok(s.msUntil(id) <= 500)
await s.close()
})
test('peer-scheduler: no background timer by default', async (t) => {
const s = new HyperP2PPeerScheduler()
t.is(s.enableBackgroundTimers, false)