@rotifer/playground 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/dist/cloud/client.d.ts +30 -0
- package/dist/cloud/client.d.ts.map +1 -1
- package/dist/cloud/client.js +118 -28
- package/dist/cloud/client.js.map +1 -1
- package/dist/commands/compare.d.ts.map +1 -1
- package/dist/commands/compare.js +3 -1
- package/dist/commands/compare.js.map +1 -1
- package/dist/commands/info.d.ts.map +1 -1
- package/dist/commands/info.js +3 -1
- package/dist/commands/info.js.map +1 -1
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +3 -1
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/network.d.ts +57 -0
- package/dist/commands/network.d.ts.map +1 -1
- package/dist/commands/network.js +289 -21
- package/dist/commands/network.js.map +1 -1
- package/dist/commands/reputation.d.ts.map +1 -1
- package/dist/commands/reputation.js +3 -1
- package/dist/commands/reputation.js.map +1 -1
- package/dist/commands/stats.d.ts.map +1 -1
- package/dist/commands/stats.js +3 -1
- package/dist/commands/stats.js.map +1 -1
- package/dist/commands/versions.d.ts.map +1 -1
- package/dist/commands/versions.js +4 -1
- package/dist/commands/versions.js.map +1 -1
- package/dist/utils/announce-table.d.ts +90 -0
- package/dist/utils/announce-table.d.ts.map +1 -0
- package/dist/utils/announce-table.js +212 -0
- package/dist/utils/announce-table.js.map +1 -0
- package/dist/utils/binding.d.ts +56 -2
- package/dist/utils/binding.d.ts.map +1 -1
- package/dist/utils/binding.js +4 -3
- package/dist/utils/binding.js.map +1 -1
- package/dist/utils/p2p-daemon.d.ts +2 -6
- package/dist/utils/p2p-daemon.d.ts.map +1 -1
- package/dist/utils/p2p-daemon.js +107 -9
- package/dist/utils/p2p-daemon.js.map +1 -1
- package/package.json +5 -6
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export interface AnnouncedGene {
|
|
2
|
+
genesRoot: string;
|
|
3
|
+
name: string;
|
|
4
|
+
geneId: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const REPUBLISH_INTERVAL_MS: number;
|
|
7
|
+
export declare const REPUBLISH_JITTER_MS: number;
|
|
8
|
+
/** After a restart, how long to wait for a first DHT peer before republishing anyway. */
|
|
9
|
+
export declare const RESTORE_WAIT_MS: number;
|
|
10
|
+
export declare function announcedTablePath(rotiferHome: string): string;
|
|
11
|
+
/** Read the table. A missing file is an empty table; a damaged one is reported, not thrown. */
|
|
12
|
+
export declare function readAnnouncedTable(path: string): {
|
|
13
|
+
entries: AnnouncedGene[];
|
|
14
|
+
problem?: string;
|
|
15
|
+
};
|
|
16
|
+
/** Write the table atomically, mode 0600, with exactly the three fields per entry. */
|
|
17
|
+
export declare function writeAnnouncedTable(path: string, entries: readonly AnnouncedGene[]): void;
|
|
18
|
+
/** Which entries a `withdraw` argument names: a v2 ID, or a gene name. */
|
|
19
|
+
export type WithdrawMatch = {
|
|
20
|
+
geneId: string;
|
|
21
|
+
} | {
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
24
|
+
export declare function matches(entry: AnnouncedGene, match: WithdrawMatch): boolean;
|
|
25
|
+
/** One scheduled republish, as the native addon reports it. */
|
|
26
|
+
export interface RepublishOutcome {
|
|
27
|
+
/** `gone`: the files no longer compute a v2 ID; `changed`: they compute another one. */
|
|
28
|
+
outcome: "republished" | "gone" | "changed" | string;
|
|
29
|
+
geneId: string;
|
|
30
|
+
recordSent: number;
|
|
31
|
+
recordAcked: number;
|
|
32
|
+
}
|
|
33
|
+
type Timer = ReturnType<typeof setTimeout>;
|
|
34
|
+
export interface RepublisherDeps {
|
|
35
|
+
path: string;
|
|
36
|
+
republish(entry: AnnouncedGene): Promise<RepublishOutcome>;
|
|
37
|
+
/** Stop providing `geneId` and drop this node's own copy of its record. */
|
|
38
|
+
withdraw(geneId: string): void;
|
|
39
|
+
hasDhtPeer(): boolean;
|
|
40
|
+
now?: () => number;
|
|
41
|
+
setTimer?: (fn: () => void, ms: number) => Timer;
|
|
42
|
+
clearTimer?: (t: Timer) => void;
|
|
43
|
+
random?: () => number;
|
|
44
|
+
log?: (line: string) => void;
|
|
45
|
+
}
|
|
46
|
+
export declare class Republisher {
|
|
47
|
+
private readonly deps;
|
|
48
|
+
private entries;
|
|
49
|
+
private readonly timers;
|
|
50
|
+
private restoreTimer;
|
|
51
|
+
private stopped;
|
|
52
|
+
private readonly now;
|
|
53
|
+
private readonly setTimer;
|
|
54
|
+
private readonly clearTimer;
|
|
55
|
+
private readonly random;
|
|
56
|
+
private readonly log;
|
|
57
|
+
constructor(deps: RepublisherDeps);
|
|
58
|
+
/** The genes being republished. */
|
|
59
|
+
list(): readonly AnnouncedGene[];
|
|
60
|
+
/**
|
|
61
|
+
* Restore the table at daemon start. Once the node has a DHT peer (or
|
|
62
|
+
* after at most 60 s) each entry is republished, then kept on its own
|
|
63
|
+
* schedule. The table holds no publish time, so the 24 h a record lives
|
|
64
|
+
* elsewhere is counted from this republish.
|
|
65
|
+
*/
|
|
66
|
+
restore(): void;
|
|
67
|
+
/** Record a gene just announced and schedule its next republish. */
|
|
68
|
+
added(entry: AnnouncedGene): void;
|
|
69
|
+
/**
|
|
70
|
+
* Stop announcing the genes `match` names. Returns them. The file is
|
|
71
|
+
* written first: if that fails nothing changes, and once it succeeds the
|
|
72
|
+
* gene stays withdrawn across a restart even if the node call throws.
|
|
73
|
+
*/
|
|
74
|
+
withdraw(match: WithdrawMatch): AnnouncedGene[];
|
|
75
|
+
/** Cancel every pending republish and the restore wait (the daemon is stopping). */
|
|
76
|
+
stop(): void;
|
|
77
|
+
private schedule;
|
|
78
|
+
private forget;
|
|
79
|
+
private save;
|
|
80
|
+
private run;
|
|
81
|
+
/**
|
|
82
|
+
* The gene was withdrawn while its republish was in flight. The withdraw
|
|
83
|
+
* ran first, so the republish may have put the record and started
|
|
84
|
+
* providing again: withdraw once more, unless the same ID was announced
|
|
85
|
+
* again in between.
|
|
86
|
+
*/
|
|
87
|
+
private withdrawnMeanwhile;
|
|
88
|
+
}
|
|
89
|
+
export {};
|
|
90
|
+
//# sourceMappingURL=announce-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announce-table.d.ts","sourceRoot":"","sources":["../../src/utils/announce-table.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,qBAAqB,QAAmB,CAAC;AACtD,eAAO,MAAM,mBAAmB,QAAiB,CAAC;AAClD,yFAAyF;AACzF,eAAO,MAAM,eAAe,QAAY,CAAC;AAGzC,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE9D;AAOD,+FAA+F;AAC/F,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,aAAa,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAY/F;AAED,sFAAsF;AACtF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,aAAa,EAAE,GAAG,IAAI,CAQzF;AAED,0EAA0E;AAC1E,MAAM,MAAM,aAAa,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAElE,wBAAgB,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAE3E;AAED,+DAA+D;AAC/D,MAAM,WAAW,gBAAgB;IAC/B,wFAAwF;IACxF,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MA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C;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,EAAE;IAY/C,oFAAoF;IACpF,IAAI,IAAI,IAAI;IAQZ,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,MAAM;IAOd,OAAO,CAAC,IAAI;YAQE,GAAG;IAqBjB;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;CAQ3B"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Republisher = exports.RESTORE_WAIT_MS = exports.REPUBLISH_JITTER_MS = exports.REPUBLISH_INTERVAL_MS = void 0;
|
|
4
|
+
exports.announcedTablePath = announcedTablePath;
|
|
5
|
+
exports.readAnnouncedTable = readAnnouncedTable;
|
|
6
|
+
exports.writeAnnouncedTable = writeAnnouncedTable;
|
|
7
|
+
exports.matches = matches;
|
|
8
|
+
/**
|
|
9
|
+
* The daemon's republish table (A2 design v2 §7.2–§7.3).
|
|
10
|
+
*
|
|
11
|
+
* Every gene this node announced is kept in `~/.rotifer/p2p/announced.json`
|
|
12
|
+
* (mode 0600) as `{genesRoot, name, geneId}`, and republished on its own
|
|
13
|
+
* schedule: 12 h after the last publish plus a uniform jitter in [0, 60 min).
|
|
14
|
+
* The daemon restores the table when it starts, so republishing survives a
|
|
15
|
+
* restart. Timers, clock and randomness are injected so tests need no real
|
|
16
|
+
* 12 h wait.
|
|
17
|
+
*/
|
|
18
|
+
const node_fs_1 = require("node:fs");
|
|
19
|
+
const node_path_1 = require("node:path");
|
|
20
|
+
const private_fs_js_1 = require("./private-fs.js");
|
|
21
|
+
exports.REPUBLISH_INTERVAL_MS = 12 * 3600 * 1000;
|
|
22
|
+
exports.REPUBLISH_JITTER_MS = 60 * 60 * 1000;
|
|
23
|
+
/** After a restart, how long to wait for a first DHT peer before republishing anyway. */
|
|
24
|
+
exports.RESTORE_WAIT_MS = 60 * 1000;
|
|
25
|
+
const RESTORE_POLL_MS = 1000;
|
|
26
|
+
function announcedTablePath(rotiferHome) {
|
|
27
|
+
return (0, node_path_1.join)(rotiferHome, "p2p", "announced.json");
|
|
28
|
+
}
|
|
29
|
+
const isEntry = (e) => typeof e === "object" &&
|
|
30
|
+
e !== null &&
|
|
31
|
+
["genesRoot", "name", "geneId"].every((k) => typeof e[k] === "string");
|
|
32
|
+
/** Read the table. A missing file is an empty table; a damaged one is reported, not thrown. */
|
|
33
|
+
function readAnnouncedTable(path) {
|
|
34
|
+
if (!(0, node_fs_1.existsSync)(path))
|
|
35
|
+
return { entries: [] };
|
|
36
|
+
let parsed;
|
|
37
|
+
try {
|
|
38
|
+
parsed = JSON.parse((0, node_fs_1.readFileSync)(path, "utf-8"));
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
return { entries: [], problem: `${path} is not valid JSON (${err.message})` };
|
|
42
|
+
}
|
|
43
|
+
if (!Array.isArray(parsed))
|
|
44
|
+
return { entries: [], problem: `${path} is not a list` };
|
|
45
|
+
const entries = parsed.filter(isEntry);
|
|
46
|
+
const skipped = parsed.length - entries.length;
|
|
47
|
+
return skipped > 0 ? { entries, problem: `${path}: skipped ${skipped} malformed entries` } : { entries };
|
|
48
|
+
}
|
|
49
|
+
/** Write the table atomically, mode 0600, with exactly the three fields per entry. */
|
|
50
|
+
function writeAnnouncedTable(path, entries) {
|
|
51
|
+
(0, private_fs_js_1.ensurePrivateDir)((0, node_path_1.dirname)(path));
|
|
52
|
+
const rows = entries.map(({ genesRoot, name, geneId }) => ({ genesRoot, name, geneId }));
|
|
53
|
+
const tmp = `${path}.${process.pid}.tmp`;
|
|
54
|
+
(0, node_fs_1.writeFileSync)(tmp, JSON.stringify(rows, null, 2) + "\n", { mode: 0o600 });
|
|
55
|
+
(0, private_fs_js_1.tightenPrivateFile)(tmp);
|
|
56
|
+
(0, node_fs_1.renameSync)(tmp, path);
|
|
57
|
+
(0, private_fs_js_1.tightenPrivateFile)(path);
|
|
58
|
+
}
|
|
59
|
+
function matches(entry, match) {
|
|
60
|
+
return "geneId" in match ? entry.geneId === match.geneId : entry.name === match.name;
|
|
61
|
+
}
|
|
62
|
+
class Republisher {
|
|
63
|
+
deps;
|
|
64
|
+
entries = [];
|
|
65
|
+
timers = new Map();
|
|
66
|
+
restoreTimer;
|
|
67
|
+
stopped = false;
|
|
68
|
+
now;
|
|
69
|
+
setTimer;
|
|
70
|
+
clearTimer;
|
|
71
|
+
random;
|
|
72
|
+
log;
|
|
73
|
+
constructor(deps) {
|
|
74
|
+
this.deps = deps;
|
|
75
|
+
this.now = deps.now ?? Date.now;
|
|
76
|
+
this.setTimer = deps.setTimer ?? setTimeout;
|
|
77
|
+
this.clearTimer = deps.clearTimer ?? clearTimeout;
|
|
78
|
+
this.random = deps.random ?? Math.random;
|
|
79
|
+
this.log = deps.log ?? (() => { });
|
|
80
|
+
}
|
|
81
|
+
/** The genes being republished. */
|
|
82
|
+
list() {
|
|
83
|
+
return this.entries;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Restore the table at daemon start. Once the node has a DHT peer (or
|
|
87
|
+
* after at most 60 s) each entry is republished, then kept on its own
|
|
88
|
+
* schedule. The table holds no publish time, so the 24 h a record lives
|
|
89
|
+
* elsewhere is counted from this republish.
|
|
90
|
+
*/
|
|
91
|
+
restore() {
|
|
92
|
+
const { entries, problem } = readAnnouncedTable(this.deps.path);
|
|
93
|
+
if (problem)
|
|
94
|
+
this.log(`republish table: ${problem}`);
|
|
95
|
+
this.entries = entries;
|
|
96
|
+
if (entries.length === 0)
|
|
97
|
+
return;
|
|
98
|
+
const startedAt = this.now();
|
|
99
|
+
const poll = () => {
|
|
100
|
+
this.restoreTimer = undefined;
|
|
101
|
+
if (this.stopped)
|
|
102
|
+
return;
|
|
103
|
+
if (this.deps.hasDhtPeer() || this.now() - startedAt >= exports.RESTORE_WAIT_MS) {
|
|
104
|
+
for (const entry of this.entries)
|
|
105
|
+
void this.run(entry);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
this.restoreTimer = this.setTimer(poll, RESTORE_POLL_MS);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
poll();
|
|
112
|
+
}
|
|
113
|
+
/** Record a gene just announced and schedule its next republish. */
|
|
114
|
+
added(entry) {
|
|
115
|
+
for (const old of this.entries.filter((e) => e.geneId === entry.geneId || (e.genesRoot === entry.genesRoot && e.name === entry.name))) {
|
|
116
|
+
this.forget(old);
|
|
117
|
+
// The same gene files now compute another ID: stop serving the old one.
|
|
118
|
+
if (old.geneId !== entry.geneId)
|
|
119
|
+
this.deps.withdraw(old.geneId);
|
|
120
|
+
}
|
|
121
|
+
this.entries.push(entry);
|
|
122
|
+
this.save();
|
|
123
|
+
this.schedule(entry);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Stop announcing the genes `match` names. Returns them. The file is
|
|
127
|
+
* written first: if that fails nothing changes, and once it succeeds the
|
|
128
|
+
* gene stays withdrawn across a restart even if the node call throws.
|
|
129
|
+
*/
|
|
130
|
+
withdraw(match) {
|
|
131
|
+
const removed = this.entries.filter((e) => matches(e, match));
|
|
132
|
+
if (removed.length === 0)
|
|
133
|
+
return removed;
|
|
134
|
+
writeAnnouncedTable(this.deps.path, this.entries.filter((e) => !removed.includes(e)));
|
|
135
|
+
for (const entry of removed)
|
|
136
|
+
this.forget(entry);
|
|
137
|
+
for (const entry of removed)
|
|
138
|
+
this.deps.withdraw(entry.geneId);
|
|
139
|
+
return removed;
|
|
140
|
+
}
|
|
141
|
+
/** Cancel every pending republish and the restore wait (the daemon is stopping). */
|
|
142
|
+
stop() {
|
|
143
|
+
this.stopped = true;
|
|
144
|
+
if (this.restoreTimer !== undefined)
|
|
145
|
+
this.clearTimer(this.restoreTimer);
|
|
146
|
+
this.restoreTimer = undefined;
|
|
147
|
+
for (const t of this.timers.values())
|
|
148
|
+
this.clearTimer(t);
|
|
149
|
+
this.timers.clear();
|
|
150
|
+
}
|
|
151
|
+
schedule(entry) {
|
|
152
|
+
const delay = exports.REPUBLISH_INTERVAL_MS + Math.floor(this.random() * exports.REPUBLISH_JITTER_MS);
|
|
153
|
+
this.timers.set(entry, this.setTimer(() => void this.run(entry), delay));
|
|
154
|
+
}
|
|
155
|
+
forget(entry) {
|
|
156
|
+
const t = this.timers.get(entry);
|
|
157
|
+
if (t !== undefined)
|
|
158
|
+
this.clearTimer(t);
|
|
159
|
+
this.timers.delete(entry);
|
|
160
|
+
this.entries = this.entries.filter((e) => e !== entry);
|
|
161
|
+
}
|
|
162
|
+
save() {
|
|
163
|
+
try {
|
|
164
|
+
writeAnnouncedTable(this.deps.path, this.entries);
|
|
165
|
+
}
|
|
166
|
+
catch (err) {
|
|
167
|
+
this.log(`republish table not saved: ${err.message}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
async run(entry) {
|
|
171
|
+
this.timers.delete(entry);
|
|
172
|
+
if (!this.entries.includes(entry))
|
|
173
|
+
return;
|
|
174
|
+
try {
|
|
175
|
+
const result = await this.deps.republish(entry);
|
|
176
|
+
if (!this.entries.includes(entry))
|
|
177
|
+
return this.withdrawnMeanwhile(entry);
|
|
178
|
+
if (result.outcome !== "republished") {
|
|
179
|
+
// §7.2: the files are gone or compute another ID → drop and stop serving.
|
|
180
|
+
this.log(`stopped republishing '${entry.name}' (${entry.geneId}): ${result.outcome}`);
|
|
181
|
+
this.forget(entry);
|
|
182
|
+
this.deps.withdraw(entry.geneId);
|
|
183
|
+
this.save();
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
catch (err) {
|
|
188
|
+
this.log(`republish of '${entry.name}' failed: ${err.message}`);
|
|
189
|
+
if (!this.entries.includes(entry))
|
|
190
|
+
return this.withdrawnMeanwhile(entry);
|
|
191
|
+
}
|
|
192
|
+
this.schedule(entry);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The gene was withdrawn while its republish was in flight. The withdraw
|
|
196
|
+
* ran first, so the republish may have put the record and started
|
|
197
|
+
* providing again: withdraw once more, unless the same ID was announced
|
|
198
|
+
* again in between.
|
|
199
|
+
*/
|
|
200
|
+
withdrawnMeanwhile(entry) {
|
|
201
|
+
if (this.entries.some((e) => e.geneId === entry.geneId))
|
|
202
|
+
return;
|
|
203
|
+
try {
|
|
204
|
+
this.deps.withdraw(entry.geneId);
|
|
205
|
+
}
|
|
206
|
+
catch (err) {
|
|
207
|
+
this.log(`withdraw of '${entry.name}' after its republish failed: ${err.message}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
exports.Republisher = Republisher;
|
|
212
|
+
//# sourceMappingURL=announce-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"announce-table.js","sourceRoot":"","sources":["../../src/utils/announce-table.ts"],"names":[],"mappings":";;;AA0BA,gDAEC;AAQD,gDAYC;AAGD,kDAQC;AAKD,0BAEC;AAlED;;;;;;;;;GASG;AACH,qCAA8E;AAC9E,yCAA0C;AAC1C,mDAAuE;AAQ1D,QAAA,qBAAqB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AACzC,QAAA,mBAAmB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAClD,yFAAyF;AAC5E,QAAA,eAAe,GAAG,EAAE,GAAG,IAAI,CAAC;AACzC,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B,SAAgB,kBAAkB,CAAC,WAAmB;IACpD,OAAO,IAAA,gBAAI,EAAC,WAAW,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,CAAU,EAAsB,EAAE,CACjD,OAAO,CAAC,KAAK,QAAQ;IACrB,CAAC,KAAK,IAAI;IACV,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAQ,CAA6B,CAAC,CAAC,CAAC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EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,CAAC;YAAE,OAAO;QAChE,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,gBAAgB,KAAK,CAAC,IAAI,iCAAkC,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QAChG,CAAC;IACH,CAAC;CACF;AAlJD,kCAkJC"}
|
package/dist/utils/binding.d.ts
CHANGED
|
@@ -55,26 +55,80 @@ export interface ReceivedAnnouncement {
|
|
|
55
55
|
publisher: string;
|
|
56
56
|
source?: string;
|
|
57
57
|
}
|
|
58
|
+
/** One publisher's copy of a gene found by a network search (mirrors Rust). */
|
|
59
|
+
export interface NetworkSearchHit {
|
|
60
|
+
geneId: string;
|
|
61
|
+
name: string;
|
|
62
|
+
domain: string;
|
|
63
|
+
version: string;
|
|
64
|
+
fidelity: string;
|
|
65
|
+
irSpec: string;
|
|
66
|
+
timestampMs: number;
|
|
67
|
+
publisher: string;
|
|
68
|
+
/** Where it was found: `dht`, `gossip` or `both`. */
|
|
69
|
+
source: "dht" | "gossip" | "both";
|
|
70
|
+
/** The publisher's registered account as the node knows it; absent if unregistered. */
|
|
71
|
+
account?: string;
|
|
72
|
+
}
|
|
73
|
+
/** What a network search found within its 3-second deadline. */
|
|
74
|
+
export interface NetworkSearchResult {
|
|
75
|
+
hits: NetworkSearchHit[];
|
|
76
|
+
/** The deadline was hit with lookups still running. */
|
|
77
|
+
timedOut: boolean;
|
|
78
|
+
/** Results may be incomplete (deadline or a candidate cap). */
|
|
79
|
+
partial: boolean;
|
|
80
|
+
}
|
|
81
|
+
/** Counts one announce observed (A2 design v2 §10.2). */
|
|
82
|
+
export interface NetworkAnnounceReport {
|
|
83
|
+
geneId: string;
|
|
84
|
+
gossipPeers: number;
|
|
85
|
+
recordSent: number;
|
|
86
|
+
recordAcked: number;
|
|
87
|
+
readableFrom: number;
|
|
88
|
+
}
|
|
58
89
|
/**
|
|
59
90
|
* Subset of the native `P2pNode` class surfaced to the CLI. Method names are
|
|
60
91
|
* camelCase (napi converts the Rust snake_case automatically).
|
|
61
92
|
*/
|
|
93
|
+
/** One scheduled republish (A2 design v2 §7.2). */
|
|
94
|
+
export interface NetworkRepublishResult {
|
|
95
|
+
/** `gone`: the files no longer compute a v2 ID; `changed`: they compute another one. */
|
|
96
|
+
outcome: string;
|
|
97
|
+
geneId: string;
|
|
98
|
+
recordSent: number;
|
|
99
|
+
recordAcked: number;
|
|
100
|
+
}
|
|
62
101
|
export interface P2pNodeHandle {
|
|
63
102
|
start(): void;
|
|
64
103
|
peerId(): string;
|
|
65
104
|
listenAddrs(): string[];
|
|
66
105
|
discoveredPeers(): string[];
|
|
106
|
+
/** Peers in the DHT routing table right now (absent in addons before A2 §8.1). */
|
|
107
|
+
dhtPeers?(): string[];
|
|
108
|
+
/** Peers with an open connection right now, DHT or not (absent likewise). */
|
|
109
|
+
connectedPeers?(): string[];
|
|
67
110
|
receivedAnnouncements(): ReceivedAnnouncement[];
|
|
68
111
|
/** Announce the local gene `name` under `genesRoot`; returns its v2 ID. */
|
|
69
112
|
announceLocalGene(genesRoot: string, name: string): string;
|
|
113
|
+
/** Search the DHT and gossip for one v2 ID (absent in addons before A2 PR-3). */
|
|
114
|
+
searchGene?(geneId: string): Promise<NetworkSearchResult>;
|
|
115
|
+
/** Match name or domain among announcements heard on gossip (absent likewise). */
|
|
116
|
+
searchKeyword?(query: string): Promise<NetworkSearchResult>;
|
|
117
|
+
/** Announce over gossip and the DHT, reporting what was observed (absent likewise). */
|
|
118
|
+
announceLocalGeneReport?(genesRoot: string, name: string): Promise<NetworkAnnounceReport>;
|
|
119
|
+
/** Republish the record and provider entry if the files still compute `geneId` (absent before A2 PR-4). */
|
|
120
|
+
republishLocalGene?(genesRoot: string, name: string, geneId: string): Promise<NetworkRepublishResult>;
|
|
121
|
+
/** Stop providing `geneId` and drop this node's own copy of its record (absent likewise). */
|
|
122
|
+
withdrawGene?(geneId: string): void;
|
|
70
123
|
stop(): void;
|
|
71
124
|
}
|
|
72
125
|
/**
|
|
73
126
|
* Construct a native libp2p P2P node. Returns null when the native addon is
|
|
74
127
|
* unavailable (e.g. a pure-TS environment without the compiled `.node`), so
|
|
75
|
-
* callers can degrade gracefully.
|
|
128
|
+
* callers can degrade gracefully. mDNS LAN discovery is off unless asked for
|
|
129
|
+
* (ADR-313: no default exposure); the daemon passes the CLI's `--no-mdns` choice.
|
|
76
130
|
*/
|
|
77
|
-
export declare function loadP2pNode(listenHost: string, listenPort: number, bootstrapPeers: string[]): P2pNodeHandle | null;
|
|
131
|
+
export declare function loadP2pNode(listenHost: string, listenPort: number, bootstrapPeers: string[], shouldUseMdns?: boolean): P2pNodeHandle | null;
|
|
78
132
|
/** Outcome of computing a gene's v2 ID: the ID, or why it has none. */
|
|
79
133
|
export type GeneIdV2Result = {
|
|
80
134
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../../src/utils/binding.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,EAA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,mGAAmG;AACnG,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C"}
|
package/dist/utils/binding.js
CHANGED
|
@@ -75,16 +75,17 @@ function tryLoadBinding() {
|
|
|
75
75
|
/**
|
|
76
76
|
* Construct a native libp2p P2P node. Returns null when the native addon is
|
|
77
77
|
* unavailable (e.g. a pure-TS environment without the compiled `.node`), so
|
|
78
|
-
* callers can degrade gracefully.
|
|
78
|
+
* callers can degrade gracefully. mDNS LAN discovery is off unless asked for
|
|
79
|
+
* (ADR-313: no default exposure); the daemon passes the CLI's `--no-mdns` choice.
|
|
79
80
|
*/
|
|
80
|
-
function loadP2pNode(listenHost, listenPort, bootstrapPeers) {
|
|
81
|
+
function loadP2pNode(listenHost, listenPort, bootstrapPeers, shouldUseMdns = false) {
|
|
81
82
|
const mod = loadRawModule();
|
|
82
83
|
// napi renders the Rust `P2pNode` as `P2PNode` (it uppercases the "p2p"
|
|
83
84
|
// acronym); accept either spelling so both the raw addon and any JS wrapper work.
|
|
84
85
|
const Ctor = (mod?.P2PNode ?? mod?.P2pNode);
|
|
85
86
|
if (typeof Ctor !== "function")
|
|
86
87
|
return null;
|
|
87
|
-
return new Ctor(listenHost, listenPort, bootstrapPeers);
|
|
88
|
+
return new Ctor(listenHost, listenPort, bootstrapPeers, shouldUseMdns);
|
|
88
89
|
}
|
|
89
90
|
/**
|
|
90
91
|
* Gene ID v2 of the gene `name` under `genesRoot` (docs/gene-id-v2.md).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding.js","sourceRoot":"","sources":["../../src/utils/binding.ts"],"names":[],"mappings":";;AAoIA,wCAMC;
|
|
1
|
+
{"version":3,"file":"binding.js","sourceRoot":"","sources":["../../src/utils/binding.ts"],"names":[],"mappings":";;AAoIA,wCAMC;AA8FD,kCAcC;AAUD,4BAQC;AAGD,8CAEC;AAED,8CAEC;AAjRD,yCAAiC;AACjC,qCAAqC;AACrC,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KD;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,SAAiB,EAAE,IAAY;IACtD,MAAM,EAAE,GAAG,aAAa,EAAE,EAAE,QAAgE,CAAC;IAC7F,IAAI,OAAO,EAAE,KAAK,UAAU;QAAE,OAAO,EAAE,MAAM,EAAE,6BAA6B,EAAE,CAAC;IAC/E,IAAI,CAAC;QACH,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC;IACrC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,MAAM,EAAG,GAAa,CAAC,OAAO,CAAC,OAAO,CAAC,2BAA2B,EAAE,EAAE,CAAC,EAAE,CAAC;IACrF,CAAC;AACH,CAAC;AAED,mGAAmG;AACnG,SAAgB,iBAAiB;IAC/B,OAAO,OAAO,aAAa,EAAE,EAAE,QAAQ,KAAK,UAAU,CAAC;AACzD,CAAC;AAED,SAAgB,iBAAiB;IAC/B,OAAO,cAAc,EAAE,KAAK,IAAI,CAAC;AACnC,CAAC"}
|
|
@@ -14,11 +14,7 @@ export interface ControlResult {
|
|
|
14
14
|
status: number;
|
|
15
15
|
body: unknown;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
* Send a control request to the running daemon. Returns null when no daemon is
|
|
19
|
-
* recorded or it is unreachable (so callers can report "not running").
|
|
20
|
-
*/
|
|
21
|
-
export declare function controlRequest(method: string, path: string, body?: unknown): Promise<ControlResult | null>;
|
|
17
|
+
export declare function controlRequest(method: string, path: string, body?: unknown, timeoutMs?: number): Promise<ControlResult | null>;
|
|
22
18
|
/** Whether a daemon is recorded and answering its control server. */
|
|
23
19
|
export declare function isDaemonRunning(): Promise<boolean>;
|
|
24
20
|
/**
|
|
@@ -26,5 +22,5 @@ export declare function isDaemonRunning(): Promise<boolean>;
|
|
|
26
22
|
* server, record the state file, and stay alive until stopped. Called from the
|
|
27
23
|
* hidden `network __daemon` subcommand in a detached process.
|
|
28
24
|
*/
|
|
29
|
-
export declare function runDaemon(listenHost: string, listenPort: number, bootstrapPeers: string[]): Promise<void>;
|
|
25
|
+
export declare function runDaemon(listenHost: string, listenPort: number, bootstrapPeers: string[], shouldUseMdns: boolean): Promise<void>;
|
|
30
26
|
//# sourceMappingURL=p2p-daemon.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p2p-daemon.d.ts","sourceRoot":"","sources":["../../src/utils/p2p-daemon.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"p2p-daemon.d.ts","sourceRoot":"","sources":["../../src/utils/p2p-daemon.ts"],"names":[],"mappings":"AA6BA,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,eAAe,IAAI,WAAW,GAAG,IAAI,CAOpD;AAQD,wBAAgB,gBAAgB,IAAI,IAAI,CAMvC;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;CACf;AAeD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,SAAS,SAAiC,GACzC,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CA6C/B;AAED,qEAAqE;AACrE,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAGxD;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EAAE,EACxB,aAAa,EAAE,OAAO,GACrB,OAAO,CAAC,IAAI,CAAC,CA2Lf"}
|