Updates
This commit is contained in:
@@ -12,44 +12,44 @@ const mod = new HyperP2PTimeCapsule(opts)
|
||||
|
||||
| Option | Type | Default | Description |
|
||||
|--------|------|---------|-------------|
|
||||
| `topic` | `string` \| `Buffer` | `null` | Hyperswarm topic; enables P2P when set |
|
||||
| `keyPair` | `KeyPair` | random | Ed25519 key pair (`hypercore-crypto`) |
|
||||
| `enableBackgroundTimers` | `boolean` | `false` | Periodic timers (keep false in unit tests) |
|
||||
| `topic` | `string` \| `Buffer` | `null` | Hyperswarm topic |
|
||||
| `keyPair` | `KeyPair` | random | Ed25519 key pair |
|
||||
| `enableBackgroundTimers` | `boolean` | `false` | Background timers (off in tests) |
|
||||
|
||||
## Methods
|
||||
|
||||
| Method | Returns | Notes |
|
||||
|--------|---------|-------|
|
||||
| `attest(...)` | See source | — |
|
||||
| `canOpen(...)` | See source | — |
|
||||
| `close(...)` | See source | — |
|
||||
| `getCapsule(...)` | See source | — |
|
||||
| `open(...)` | See source | — |
|
||||
| `ready(...)` | See source | — |
|
||||
| `seal(...)` | See source | — |
|
||||
| Method | Returns | Throws |
|
||||
|--------|---------|--------|
|
||||
| `getStats()` | `object` | — |
|
||||
| `close()` | `Promise<void>` | — |
|
||||
| `attest(...)` | `Promise` or value | May throw `Error` on invalid input |
|
||||
| `canOpen(...)` | `Promise` or value | May throw `Error` on invalid input |
|
||||
| `getCapsule(...)` | `Promise` or value | May throw `Error` on invalid input |
|
||||
| `open(...)` | `Promise` or value | May throw `Error` on invalid input |
|
||||
| `ready(...)` | `Promise` or value | May throw `Error` on invalid input |
|
||||
| `seal(...)` | `Promise` or value | May throw `Error` on invalid input |
|
||||
|
||||
## Events
|
||||
|
||||
| Event | Description |
|
||||
|-------|-------------|
|
||||
| `attest` | Module-specific |
|
||||
| `closed` | Module-specific |
|
||||
| `open` | Module-specific |
|
||||
| `seal` | Module-specific |
|
||||
| `attest` | Emitted on state change |
|
||||
| `closed` | Emitted on state change |
|
||||
| `open` | Emitted on state change |
|
||||
| `seal` | Emitted on state change |
|
||||
|
||||
## Metrics
|
||||
|
||||
Call `getStats()` when implemented for counters (Wave 6 network modules always expose stats).
|
||||
`getStats()` returns operation counters (`ops`, `errors`, etc.) or `mode: 'local'` for library-only modules.
|
||||
|
||||
## P2P
|
||||
|
||||
When `topic` is set, `ready()` joins Hyperswarm and opens Protomux `time-capsule/v1` via [`_shared/p2p-bare.js`](../_shared/p2p-bare.js).
|
||||
When `topic` is set, `ready()` joins Hyperswarm and opens Protomux `time-capsule/v1`.
|
||||
|
||||
## Testing
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm test
|
||||
npm install && npm test
|
||||
```
|
||||
|
||||
Integration: [`../../real_tests/integration/time-capsule-two-node.js`](../../real_tests/integration/time-capsule-two-node.js)
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
# Architecture: hyper-p2p-time-capsule
|
||||
|
||||
Time and quorum locked payloads for Bare/Pear P2P overlays.
|
||||
**Category:** Experimental (Wave 4)
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
flowchart LR
|
||||
App[Application] --> Mod[HyperP2PTimeCapsule]
|
||||
Mod --> Mux[Protomux time-capsule/v1]
|
||||
Mux --> Swarm[Hyperswarm topic]
|
||||
Mux --> Swarm[Hyperswarm]
|
||||
```
|
||||
|
||||
## Wire messages (gossip)
|
||||
## Wire messages
|
||||
|
||||
JSON envelopes via `gossipSend` when connected. Message `type` fields are module-specific; see `index.js` `onmessage` handler.
|
||||
| type | payload | direction |
|
||||
|------|---------|-----------|
|
||||
| `attest` | JSON payload | gossip |
|
||||
| `open` | JSON payload | gossip |
|
||||
| `seal` | JSON payload | gossip |
|
||||
|
||||
## Composition (Wave 6)
|
||||
## Composition
|
||||
|
||||
See [`../_shared/WAVE6_NETWORK_STACK.md`](../_shared/WAVE6_NETWORK_STACK.md) for pairing with network-stack modules.
|
||||
Composes with: `hyper-p2p-pheromone-trail`, `hyper-p2p-whisper-mesh`, `hyper-p2p-entropy-beacon`.
|
||||
|
||||
See [`../_shared/WAVE6_NETWORK_STACK.md`](../_shared/WAVE6_NETWORK_STACK.md) when using network-stack modules.
|
||||
|
||||
## State
|
||||
|
||||
In-memory maps/arrays; merged from remote gossip when `topic` is configured.
|
||||
In-memory structures; gossip merges remote updates when `topic` is configured.
|
||||
|
||||
Reference in New Issue
Block a user