Update Docs

This commit is contained in:
Raven Scott
2026-05-20 20:55:52 -04:00
parent 260dc9da44
commit 1f3f4b24a2
215 changed files with 8565 additions and 2444 deletions
+61 -24
View File
@@ -4,6 +4,10 @@
**Export:** `HyperP2PQuorumPool`
## Overview
Library-only consensus & coordination primitive for Bare/Pear (no mandatory Hyperswarm topic).
## Constructor
```js
@@ -12,40 +16,73 @@ const mod = new HyperP2PQuorumPool(opts)
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `topic` | `string` \| `Buffer` | `null` | Hyperswarm topic |
| `keyPair` | `KeyPair` | random | Ed25519 key pair |
| `enableBackgroundTimers` | `boolean` | `false` | Background timers (off in tests) |
| `quorum` | varies | module default | See constructor |
| `topic` | `string` | `Buffer` | `null` | Hyperswarm topic; required for P2P `ready()` |
| `keyPair` | KeyPair | random | Ed25519 key pair |
| `quorum` | number | 0.51 | quorum |
## Methods
| Method | Returns | Throws |
|--------|---------|--------|
| `getStats()` | `object` | — |
| `close()` | `Promise<void>` | — |
| `addMember(...)` | `Promise` or value | May throw `Error` on invalid input |
| `getProposal(...)` | `Promise` or value | May throw `Error` on invalid input |
| `propose(...)` | `Promise` or value | May throw `Error` on invalid input |
| `resolve(...)` | `Promise` or value | May throw `Error` on invalid input |
| `setMembers(...)` | `Promise` or value | May throw `Error` on invalid input |
| `vote(...)` | `Promise` or value | May throw `Error` on invalid input |
### `setMembers(members)`
- **Returns:** `value`
- **Throws:** — (none documented in method body)
### `addMember(id)`
- **Returns:** `value`
- **Throws:** — (none documented in method body)
### `propose(payload)`
- **Returns:** `value`
- **Throws:** — (none documented in method body)
### `vote(proposalId, voterId, accept = true)`
- **Returns:** `value`
- **Throws:** — (none documented in method body)
### `resolve(proposalId)`
- **Returns:** `value`
- **Throws:** — (none documented in method body)
### `getProposal(id)`
- **Returns:** `value`
- **Throws:** — (none documented in method body)
### `getStats(—)`
- **Returns:** `object`
- **Throws:** — (none documented in method body)
### `close(—)`
- **Returns:** `Promise<void>`
- **Throws:** — (none documented in method body)
## Events
| Event | Description |
|-------|-------------|
| `closed` | Emitted on state change |
| `propose` | Emitted on state change |
| `resolve` | Emitted on state change |
| `vote` | Emitted on state change |
| Event | Payload |
|-------|---------|
| `closed` | no payload |
| `propose` | payload object |
| `resolve` | result |
| `vote` | voterId |
## Metrics
## getStats()
`getStats()` returns operation counters (`ops`, `errors`, etc.) or `mode: 'local'` for library-only modules.
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).
## P2P
When `topic` is set, `ready()` joins Hyperswarm and opens Protomux `quorum-pool/v1`.
No Hyperswarm topic required; use Protomux attach helpers where documented.
## Testing
@@ -53,4 +90,4 @@ When `topic` is set, `ready()` joins Hyperswarm and opens Protomux `quorum-pool/
npm install && npm test
```
Integration: [`../../real_tests/integration/quorum-pool-two-node.js`](../../real_tests/integration/quorum-pool-two-node.js)
Integration: [`../../real_tests/integration/quorum-pool-two-node.js`](../../real_tests/integration/quorum-pool-two-node.js)
+9 -8
View File
@@ -11,16 +11,17 @@ flowchart LR
## Wire messages
| type | payload | direction |
|------|---------|-----------|
| *(local only)* | — | — |
| type | fields | direction | behavior |
|------|--------|-----------|----------|
| *(local only)* | — | — | No gossip wire types |
## State model
- In-memory `Map` / `Set` structures for hot path
- Optional Hyperbee/Hypercore persistence when `storageDir` or `memoryOnly` is configured
- `close()` tears down swarm, timers, and clears ephemeral state
## Composition
Composes with: `hyper-p2p-distributed-lock`, `hyper-p2p-causal-consensus`.
See [`../_shared/WAVE6_NETWORK_STACK.md`](../_shared/WAVE6_NETWORK_STACK.md) when using network-stack modules.
## State
In-memory structures; gossip merges remote updates when `topic` is configured.