*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("removeRelay", handleRemoveRelay);
|
||||
addHandler("clearRelays", handleClearRelays);
|
||||
addHandler("getRelays", handleGetRelays);
|
||||
addHandler("ready", handleReady);
|
||||
|
||||
async function handlePresentSeed(aq: ActiveQuery) {
|
||||
|
@ -258,6 +259,16 @@ function handleClearRelays(aq: ActiveQuery) {
|
|||
aq.respond();
|
||||
}
|
||||
|
||||
function handleGetRelays(aq: ActiveQuery) {
|
||||
const dht = validateDht(aq);
|
||||
|
||||
if (!dht) {
|
||||
return;
|
||||
}
|
||||
|
||||
aq.respond(dht.relays);
|
||||
}
|
||||
|
||||
async function handleReady(aq: ActiveQuery) {
|
||||
const dht = validateDht(aq);
|
||||
|
||||
|
|
Loading…
Reference in New Issue