Updates
This commit is contained in:
@@ -6,3 +6,6 @@
|
||||
## v0.2.0
|
||||
|
||||
- Production-grade docs, validation, and expanded tests.
|
||||
## v0.3.0
|
||||
|
||||
- Wave 6: presence-tier API tables, architecture wire section, validation test.
|
||||
|
||||
@@ -18,15 +18,32 @@ const mod = new HyperP2PMyceliumPool(opts)
|
||||
|
||||
## Methods
|
||||
|
||||
See [`index.js`](../index.js) for the full method list. Core operations implement **symbiotic bandwidth credit pool**.
|
||||
| Method | Returns | Notes |
|
||||
|--------|---------|-------|
|
||||
| `balance(...)` | See source | — |
|
||||
| `borrow(...)` | See source | — |
|
||||
| `close(...)` | See source | — |
|
||||
| `donate(...)` | See source | — |
|
||||
| `mergeBalances(...)` | See source | — |
|
||||
| `ready(...)` | See source | — |
|
||||
| `repay(...)` | See source | — |
|
||||
| `toJSON(...)` | See source | — |
|
||||
|
||||
## Events
|
||||
|
||||
The instance extends `EventEmitter`. Common events: `closed`, plus module-specific events documented in source.
|
||||
| Event | Description |
|
||||
|-------|-------------|
|
||||
| `borrow` | Module-specific |
|
||||
| `closed` | Module-specific |
|
||||
| `donate` | Module-specific |
|
||||
|
||||
## Metrics
|
||||
|
||||
Call `getStats()` when implemented for counters (Wave 6 network modules always expose stats).
|
||||
|
||||
## P2P
|
||||
|
||||
When `topic` is set, `ready()` joins Hyperswarm and opens Protomux channel `mycelium-pool/v1` via [`_shared/p2p-bare.js`](../_shared/p2p-bare.js).
|
||||
When `topic` is set, `ready()` joins Hyperswarm and opens Protomux `mycelium-pool/v1` via [`_shared/p2p-bare.js`](../_shared/p2p-bare.js).
|
||||
|
||||
## Testing
|
||||
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
# Architecture: hyper-p2p-mycelium-pool
|
||||
|
||||
Symbiotic bandwidth credit pool for Bare/Pear P2P overlays.
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
flowchart TB
|
||||
App[Application] --> Mod[HyperP2PMyceliumPool]
|
||||
Mod --> P2P[Protomux mycelium-pool/v1]
|
||||
P2P --> Swarm[Hyperswarm]
|
||||
Mod --> Mux[Protomux mycelium-pool/v1]
|
||||
Mux --> Swarm[Hyperswarm topic]
|
||||
```
|
||||
|
||||
Local state lives in memory maps/arrays; gossip merges remote updates when `topic` is configured.
|
||||
## Wire messages (gossip)
|
||||
|
||||
JSON envelopes via `gossipSend` when connected. Message `type` fields are module-specific; see `index.js` `onmessage` handler.
|
||||
|
||||
## Composition (Wave 6)
|
||||
|
||||
See [`../_shared/WAVE6_NETWORK_STACK.md`](../_shared/WAVE6_NETWORK_STACK.md) for pairing with network-stack modules.
|
||||
|
||||
## State
|
||||
|
||||
In-memory maps/arrays; merged from remote gossip when `topic` is configured.
|
||||
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "hyper-p2p-mycelium-pool",
|
||||
"version": "0.2.0",
|
||||
"version": "0.3.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "hyper-p2p-mycelium-pool",
|
||||
"version": "0.2.0",
|
||||
"version": "0.3.0",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"b4a": "^1.6.7",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hyper-p2p-mycelium-pool",
|
||||
"version": "0.2.0",
|
||||
"version": "0.3.0",
|
||||
"description": "Symbiotic bandwidth credit pool for Bare/Pear P2P.",
|
||||
"main": "index.js",
|
||||
"type": "commonjs",
|
||||
|
||||
@@ -35,3 +35,22 @@ test('hyper-p2p-mycelium-pool: close without leak', async (t) => {
|
||||
await m.close()
|
||||
t.pass()
|
||||
})
|
||||
test('hyper-p2p-mycelium-pool: validation rejects invalid input', async (t) => {
|
||||
const m = new HyperP2PMyceliumPool()
|
||||
try {
|
||||
if (typeof m.addNeighbor === 'function') m.addNeighbor(null)
|
||||
else if (typeof m.buildCircuit === 'function') m.buildCircuit([])
|
||||
else if (typeof m.grant === 'function') m.grant(null, -1)
|
||||
else if (typeof m.enqueue === 'function') m.enqueue('bad', null)
|
||||
else if (typeof m.reportSample === 'function') m.reportSample(null, -1, -1)
|
||||
else if (typeof m.fanout === 'function') m.fanout(null, 0)
|
||||
else if (typeof m.probe === 'function') m.probe(null)
|
||||
else if (typeof m.resolve === 'function') m.resolve(null)
|
||||
else if (typeof m.acquire === 'function') m.acquire(null)
|
||||
else throw new Error('no validation hook')
|
||||
t.fail('expected throw')
|
||||
} catch (err) {
|
||||
t.ok(err instanceof Error)
|
||||
}
|
||||
await m.close()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user