Deepen supercomputer category with shared base and expanded APIs.
Adds supercomputer-base helpers, richer job/shard/steal/thermal modules, priority jobs, claimMatching, and bumps all 14 modules to 0.3.1. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -2,6 +2,7 @@ require('bare-process/global')
|
||||
const EventEmitter = require('bare-events')
|
||||
const b4a = require('b4a')
|
||||
const { initModuleSwarm, gossipSend } = require('../../_shared/p2p-bare.js')
|
||||
const { normalizePeerId, clusterStats } = require('../../_shared/supercomputer-base.js')
|
||||
|
||||
const PROTOCOL = 'net-gateway/v1'
|
||||
|
||||
@@ -70,6 +71,20 @@ class HyperP2PNetGateway extends EventEmitter {
|
||||
return t
|
||||
}
|
||||
|
||||
routeForRegion (bytes, region) {
|
||||
for (const g of this._gateways.values()) {
|
||||
if ((g.regions || []).includes(region)) {
|
||||
const hit = this.requestRoute(bytes, g.peerId)
|
||||
if (hit) return hit
|
||||
}
|
||||
}
|
||||
return this.requestRoute(bytes)
|
||||
}
|
||||
|
||||
usageFor (peerId) {
|
||||
return this._usage.get(normalizePeerId(peerId)) || 0
|
||||
}
|
||||
|
||||
async ready () {
|
||||
if (this.swarm || !this.topic) return this
|
||||
await initModuleSwarm(this, {
|
||||
@@ -88,7 +103,10 @@ class HyperP2PNetGateway extends EventEmitter {
|
||||
}
|
||||
|
||||
getStats () {
|
||||
return { ...this._stats, gateways: this._gateways.size, protocol: PROTOCOL }
|
||||
return clusterStats(this._stats, PROTOCOL, {
|
||||
gateways: this._gateways.size,
|
||||
capacityBytes: this.totalCapacityBytes()
|
||||
})
|
||||
}
|
||||
|
||||
async close () {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hyper-p2p-net-gateway",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.1",
|
||||
"description": "Peer internet egress gateway credits for Bare/Pear P2P supercomputer mesh.",
|
||||
"main": "index.js",
|
||||
"type": "commonjs",
|
||||
|
||||
Reference in New Issue
Block a user