Expand category docs and module APIs across the library.
Manual pass adds helpers (listChannels, taskCounts, openProposals), richer getStats with protocol fields, category README hubs, and tightened api.md for core, messaging, network, routing, supercomputer, and consensus modules. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
# API: hyper-p2p-relay-tunnel
|
||||
|
||||
**Protocol:** `relay-tunnel/v1`
|
||||
|
||||
**Export:** `HyperP2PRelayTunnel`
|
||||
**Protocol:** `relay-tunnel/v1` · **Export:** `HyperP2PRelayTunnel`
|
||||
|
||||
## Overview
|
||||
|
||||
Production routing & paths module: Hyperswarm discovery + Protomux when `topic` is set.
|
||||
`HyperP2PRelayTunnel` — P2P module. See [`README.md`](../README.md) and [`architecture.md`](architecture.md).
|
||||
|
||||
## Constructor
|
||||
|
||||
@@ -16,80 +14,49 @@ const mod = new HyperP2PRelayTunnel(opts)
|
||||
|
||||
| Option | Type | Default | Description |
|
||||
|--------|------|---------|-------------|
|
||||
| `topic` | varies | null | topic |
|
||||
| `keyPair` | KeyPair | random Ed25519 | keyPair |
|
||||
| `rendezvous` | varies | 'default' | rendezvous |
|
||||
| `topic` | Buffer \| string \| null | `null` | Hyperswarm topic; omit for local-only |
|
||||
| `keyPair` | KeyPair | random | Discovery identity |
|
||||
|
||||
## Methods
|
||||
|
||||
### `advertise(rendezvousKey = null)`
|
||||
### `advertise(...)`
|
||||
|
||||
- **Returns:** `value`
|
||||
- **Throws:** — (none documented in method body)
|
||||
Public API on `HyperP2PRelayTunnel`. See [`index.js`](../index.js) for parameters and return types.
|
||||
|
||||
### `findRelay(rendezvousKey = null)`
|
||||
### `findRelay(...)`
|
||||
|
||||
- **Returns:** `value`
|
||||
- **Throws:** — (none documented in method body)
|
||||
Public API on `HyperP2PRelayTunnel`. See [`index.js`](../index.js) for parameters and return types.
|
||||
|
||||
### `connect(rendezvousKey, targetPeer = null)`
|
||||
### `connect(...)`
|
||||
|
||||
- **Returns:** `value`
|
||||
- **Throws:** — (none documented in method body)
|
||||
Public API on `HyperP2PRelayTunnel`. See [`index.js`](../index.js) for parameters and return types.
|
||||
|
||||
### `relay(tunnelId, payload)`
|
||||
### `relay(...)`
|
||||
|
||||
- **Returns:** `value`
|
||||
- **Throws:** — (none documented in method body)
|
||||
Public API on `HyperP2PRelayTunnel`. See [`index.js`](../index.js) for parameters and return types.
|
||||
|
||||
### `closeTunnel(tunnelId)`
|
||||
### `closeTunnel(...)`
|
||||
|
||||
- **Returns:** `value`
|
||||
- **Throws:** — (none documented in method body)
|
||||
Public API on `HyperP2PRelayTunnel`. See [`index.js`](../index.js) for parameters and return types.
|
||||
|
||||
### `ready(—)`
|
||||
### `getStats() → object`
|
||||
|
||||
- **Returns:** `Promise`
|
||||
- **Throws:** — (none documented in method body)
|
||||
Metrics plus `protocol: 'relay-tunnel/v1'`.
|
||||
|
||||
### `getStats(—)`
|
||||
### `async ready()`
|
||||
|
||||
- **Returns:** `object`
|
||||
- **Throws:** — (none documented in method body)
|
||||
Joins Hyperswarm when `topic` is set; opens Protomux channel.
|
||||
|
||||
### `close(—)`
|
||||
### `async close()`
|
||||
|
||||
- **Returns:** `Promise<void>`
|
||||
- **Throws:** — (none documented in method body)
|
||||
|
||||
## Events
|
||||
|
||||
| Event | Payload |
|
||||
|-------|---------|
|
||||
| `advertise` | route |
|
||||
| `closed` | no payload |
|
||||
| `connect` | tunnel |
|
||||
| `relay` | frame |
|
||||
| `remote-relay` | data.frame |
|
||||
| `tunnel-closed` | payload object |
|
||||
|
||||
## getStats()
|
||||
|
||||
Returns `{ ...this._stats }` — typically `ops`, `errors`, and module-specific counters (`created`, `relays`, `open`, `peers`, etc.).
|
||||
Library-only modules may include `mode: 'local'`.
|
||||
|
||||
## Errors
|
||||
|
||||
Stable message substrings: see [`../_shared/ERROR_CODES.md`](../../_shared/ERROR_CODES.md).
|
||||
Tears down swarm and clears local state; emits `closed` where applicable.
|
||||
|
||||
## P2P
|
||||
|
||||
When `topic` is set, `ready()` joins Hyperswarm and opens Protomux `relay-tunnel/v1`.
|
||||
Gossip / sync over Protomux `relay-tunnel/v1` when `topic` is configured.
|
||||
|
||||
## Testing
|
||||
|
||||
```bash
|
||||
npm install && npm test
|
||||
```
|
||||
|
||||
Integration: [`../../real_tests/integration/relay-tunnel-two-node.js`](../../../real_tests/integration/relay-tunnel-two-node.js)
|
||||
Reference in New Issue
Block a user