*Add method to get current relays in a DHT instance
This commit is contained in:
parent
f8229abf66
commit
5652eccd1b
11
src/index.ts
11
src/index.ts
|
@ -32,6 +32,7 @@ addHandler("write", handleWriteSocketEvent);
|
||||||
addHandler("addRelay", handleAddRelay);
|
addHandler("addRelay", handleAddRelay);
|
||||||
addHandler("removeRelay", handleRemoveRelay);
|
addHandler("removeRelay", handleRemoveRelay);
|
||||||
addHandler("clearRelays", handleClearRelays);
|
addHandler("clearRelays", handleClearRelays);
|
||||||
|
addHandler("getRelays", handleGetRelays);
|
||||||
addHandler("ready", handleReady);
|
addHandler("ready", handleReady);
|
||||||
|
|
||||||
async function handlePresentSeed(aq: ActiveQuery) {
|
async function handlePresentSeed(aq: ActiveQuery) {
|
||||||
|
@ -258,6 +259,16 @@ function handleClearRelays(aq: ActiveQuery) {
|
||||||
aq.respond();
|
aq.respond();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleGetRelays(aq: ActiveQuery) {
|
||||||
|
const dht = validateDht(aq);
|
||||||
|
|
||||||
|
if (!dht) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
aq.respond(dht.relays);
|
||||||
|
}
|
||||||
|
|
||||||
async function handleReady(aq: ActiveQuery) {
|
async function handleReady(aq: ActiveQuery) {
|
||||||
const dht = validateDht(aq);
|
const dht = validateDht(aq);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue