Expose relay funcs (#31)

This commit is contained in:
Íñigo Aréjula Aísa
2022-11-26 03:21:33 +01:00
committed by GitHub
parent ae717a1a4a
commit 1b798b2eee
3 changed files with 27 additions and 3 deletions

14
pool.js
View File

@@ -144,6 +144,20 @@ export function relayPool() {
relay.close()
delete relays[relayURL]
},
//getRelayList return an array with all the relays stored
getRelayList() {
return Object.values(relays)
},
relayChangePolicy(url, policy = {read: true, write: true}) {
let relayURL = normalizeRelayURL(url)
let data = relays[relayURL]
if (!data) return
relays[relayURL].policy = policy
return relays[relayURL]
},
onNotice(cb) {
noticeCallbacks.push(cb)
},