Compare commits

..

2 Commits

Author SHA1 Message Date
fiatjaf
02cacd4446 return sub object from .sub() and other methods. 2021-12-12 06:47:52 -03:00
fiatjaf
a99188e4cf remove log line for events with invalid signature. 2021-12-12 05:54:48 -03:00
3 changed files with 7 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "nostr-tools",
"version": "0.7.1",
"version": "0.8.0",
"description": "Tools for making a Nostr client.",
"repository": {
"type": "git",

View File

@@ -29,19 +29,23 @@ export function relayPool(globalPrivateKey) {
const activeFilters = filter
activeSubscriptions[id] = {
sub: ({cb = activeCallback, filter = activeFilters}) =>
sub: ({cb = activeCallback, filter = activeFilters}) => {
Object.entries(subControllers).map(([relayURL, sub]) => [
relayURL,
sub.sub({cb, filter}, id)
]),
])
return activeSubscriptions[id]
},
addRelay: relay => {
subControllers[relay.url] = relay.sub({cb, filter})
return activeSubscriptions[id]
},
removeRelay: relayURL => {
if (relayURL in subControllers) {
subControllers[relayURL].unsub()
if (Object.keys(subControllers).length === 0) unsub()
}
return activeSubscriptions[id]
},
unsub: () => {
Object.values(subControllers).forEach(sub => sub.unsub())

View File

@@ -84,8 +84,6 @@ export function relayConnect(url, onNotice) {
if (channels[channel]) {
channels[channel](event)
}
} else {
console.warn('got event with invalid signature from ' + url, event)
}
return
}