This commit is contained in:
Raven Scott
2026-05-20 19:51:22 -04:00
parent 0f2ab198a6
commit 040f1d05ea
324 changed files with 2715 additions and 5466 deletions
+33 -1
View File
@@ -2,5 +2,37 @@
**Protocol:** `trust-graph/v1`
See `index.js` for methods. Integration: `../../real_tests/integration/trust-graph-two-node.js`.
**Export:** `HyperP2PTrustGraph`
## Constructor
```js
const mod = new HyperP2PTrustGraph(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) |
## Methods
See [`index.js`](../index.js) for the full method list. Core operations implement **transitive trust graph with decay**.
## Events
The instance extends `EventEmitter`. Common events: `closed`, plus module-specific events documented in source.
## P2P
When `topic` is set, `ready()` joins Hyperswarm and opens Protomux channel `trust-graph/v1` via [`_shared/p2p-bare.js`](../_shared/p2p-bare.js).
## Testing
```bash
npm install
npm test
```
Integration: [`../../real_tests/integration/trust-graph-two-node.js`](../../real_tests/integration/trust-graph-two-node.js)
+7 -1
View File
@@ -1,4 +1,10 @@
# Architecture: hyper-p2p-trust-graph
P2P via Hyperswarm + Protomux (`trust-graph/v1`) when `topic` is set.
```mermaid
flowchart LR
App[Application] --> Mod[HyperP2PTrustGraph]
Mod --> P2P[Protomux trust-graph/v1]
P2P --> Swarm[Hyperswarm]
```
Local state lives in memory maps/arrays; gossip merges remote updates when `topic` is configured.