holepunch-hop
Version:
data interface to HOP
31 lines (23 loc) • 2.16 kB
Markdown
# Plan: Plumbing BesearchModule into HolepunchWorker
The goal is to enable access to the `BesearchModule` (located in `src/storage/modules/besearch/besearchBee.js`) via the `HolepunchWorker` class in `src/index.js`.
## Current State
- `BesearchModule` is defined in `src/storage/modules/besearch/besearchBee.js` but is exported as `ResearchModule` (potential bug/copy-paste error) and is not imported anywhere.
- `ResearchModule` in `src/storage/modules/cues/research.js` already contains `besearch` related methods (`saveBesearch`, `getBesearch`, etc.) and is already integrated into `BeeWorker` (`src/storage/bees.js`).
- `HolepunchWorker` (`src/index.js`) manages `BeeWorker`, which in turn manages various modules including `ResearchModule`.
## Proposed Changes
### 1. Fix `BesearchModule` export and class name consistency
- In `src/storage/modules/besearch/besearchBee.js`:
- Fix the export statement (currently `export default ResearchModule`, should be `export default BesearchModule`).
### 2. Integrate `BesearchModule` into `BeeWorker`
- In `src/storage/bees.js`:
- Import `BesearchModule` from `./modules/besearch/besearchBee.js`.
- Initialize `this.Besearch` in the `setupHyperbee` method (or constructor if preferred, following existing patterns).
- Add delegate methods for `saveBesearch`, `getBesearch`, `getBesearchHistory`, and `deleteBentoBesearch` to point to `this.Besearch` instead of `this.Research` (or keep both if desired, but the user specifically asked to plumb this module).
### 3. Update `HolepunchWorker`
- In `src/index.js`:
- Update `setHOPCrypto` to include `"Besearch"` in the `modules` array so its crypto object is set correctly.
- `HolepunchWorker` already delegates many calls to `this.BeeData` (which is a `BeeWorker` instance). If we need specific methods on `HolepunchWorker` for Besearch, we can add them, or rely on `worker.BeeData.Besearch...`.
## Verification Plan
- Verify that `BesearchModule` methods are accessible via `HolepunchWorker.BeeData.Besearch`.
- Verify that `crypto` is correctly passed to `BesearchModule`.
- Run existing tests (if any) to ensure no regressions.