Updates
This commit is contained in:
@@ -1,14 +1,26 @@
|
||||
# API: hyper-p2p-peer-bootstrap-store
|
||||
|
||||
**Protocol:** `peer-bootstrap-store/v1`
|
||||
**Protocol:** `peer-bootstrap-store/v1` · **Export:** `HyperP2PPeerBootstrapStore`, `PROTOCOL`
|
||||
|
||||
**Export:** `HyperP2PPeerBootstrapStore`
|
||||
## Overview
|
||||
|
||||
Stores bootstrap hint objects per `peerId` and gossips additions. Remote entries merge LWW on `at`.
|
||||
|
||||
## Constructor
|
||||
|
||||
| Option | Type | Default | Description |
|
||||
|--------|------|---------|-------------|
|
||||
| `topic` | `string` \| `Buffer` | `null` | Swarm topic |
|
||||
| `keyPair` | `KeyPair` | random | `peerHex` |
|
||||
|
||||
## Methods
|
||||
|
||||
### `addBootstrap(peerId, hints = {})`
|
||||
### `addBootstrap(peerId, hints?)`
|
||||
|
||||
- **Returns:** `{ peerId, hints, from, at }`
|
||||
- **Returns:** `{ peerId, hints, from: peerHex, at }`
|
||||
- **Throws:** `assertNonEmpty` on `peerId`
|
||||
- **Gossip:** `{ type: 'bootstrap-add', peerId, hints, from, at }`
|
||||
- **Emits:** `add`
|
||||
|
||||
### `getBootstrap(peerId)`
|
||||
|
||||
@@ -16,18 +28,63 @@
|
||||
|
||||
### `allBootstraps()`
|
||||
|
||||
- **Returns:** `Array<entry>`
|
||||
- **Returns:** array of all entries
|
||||
|
||||
### `ready()` / `close()`
|
||||
|
||||
Clears store on close.
|
||||
|
||||
## Events
|
||||
|
||||
| Event | Payload |
|
||||
|-------|---------|
|
||||
| `add` | local entry |
|
||||
| `remote-add` | remote entry |
|
||||
| `remote-add` | merged entry |
|
||||
| `closed` | — |
|
||||
|
||||
## getStats()
|
||||
|
||||
`added`, `gossipIn`, `gossipOut`, `bootstraps`, `protocol`.
|
||||
|
||||
## Wire
|
||||
|
||||
| type | fields | behavior |
|
||||
|------|--------|----------|
|
||||
| `bootstrap-add` | `peerId`, `hints`, `from`, `at` | LWW per `peerId` |
|
||||
|
||||
## Errors
|
||||
|
||||
`assertNonEmpty` on `peerId`.
|
||||
|
||||
See [`../../_shared/ERROR_CODES.md`](../../_shared/ERROR_CODES.md).
|
||||
|
||||
## P2P
|
||||
|
||||
`from` falls back to gossip sender public key hex.
|
||||
|
||||
## Testing
|
||||
|
||||
```bash
|
||||
npm install && npm test
|
||||
cd modules/network-discovery/hyper-p2p-peer-bootstrap-store && npm test
|
||||
```
|
||||
|
||||
## Composition
|
||||
|
||||
`hyper-p2p-dht-bootstrap-hint`, `hyper-bare-bundle-bridge`, `hyper-p2p-seeder-registry`.
|
||||
|
||||
## Example
|
||||
|
||||
See [`examples/basic.js`](../examples/basic.js).
|
||||
|
||||
## Remote merge rules
|
||||
|
||||
- `bootstrap-add` LWW on `peerId` by `at`
|
||||
- `from` resolved from message or gossip `peerInfo.publicKey`
|
||||
|
||||
## Lifecycle
|
||||
|
||||
`allBootstraps()` returns live snapshot; not cached copies.
|
||||
|
||||
## See also
|
||||
|
||||
[`docs/architecture.md`](architecture.md), [`../../MODULE_CATEGORIES.md`](../../MODULE_CATEGORIES.md).
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
# Architecture: hyper-p2p-peer-bootstrap-store
|
||||
|
||||
**Category:** network-discovery
|
||||
**Protocol:** `peer-bootstrap-store/v1` · **Category:** network-discovery
|
||||
|
||||
## Wire messages
|
||||
|
||||
| type | fields | direction | behavior |
|
||||
|------|--------|-----------|----------|
|
||||
| `bootstrap-add` | `peerId`, `hints`, `from`, `at` | gossip | LWW upsert per `peerId` |
|
||||
| type | direction | fields | behavior |
|
||||
|------|-----------|--------|----------|
|
||||
| `bootstrap-add` | gossip | `peerId`, `hints`, `from`, `at` | LWW merge; emit `remote-add` |
|
||||
|
||||
## State model
|
||||
|
||||
- `_bootstraps`: `Map<peerId, entry>`
|
||||
`_bootstraps`: Map peerId → entry.
|
||||
|
||||
## Composition
|
||||
|
||||
Replicates dial hints across a gossip mesh topic.
|
||||
`hyper-p2p-dht-bootstrap-hint`, `hyper-bare-bundle-bridge`.
|
||||
|
||||
Reference in New Issue
Block a user