mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 08:38:50 +00:00
should subscribe correctly
This commit is contained in:
10
relay.js
10
relay.js
@@ -85,8 +85,7 @@ export function relayConnect(url, onNotice) {
|
||||
} else {
|
||||
console.warn(
|
||||
'got event with invalid signature from ' + url,
|
||||
event,
|
||||
id
|
||||
event
|
||||
)
|
||||
}
|
||||
return
|
||||
@@ -116,7 +115,8 @@ export function relayConnect(url, onNotice) {
|
||||
}
|
||||
}
|
||||
|
||||
const sub = async (channel, {cb, filter}) => {
|
||||
const sub = async ({cb, filter}) => {
|
||||
const channel = (await sha256(Math.random().toString())).reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '')
|
||||
trySend(['REQ', channel, filter])
|
||||
channels[channel] = cb
|
||||
|
||||
@@ -128,9 +128,9 @@ export function relayConnect(url, onNotice) {
|
||||
|
||||
return {
|
||||
url,
|
||||
sub: sub.bind(null, await sha256(Math.random().toString())),
|
||||
sub,
|
||||
async publish(event) {
|
||||
trySend(JSON.stringify(['EVENT', event]))
|
||||
trySend(['EVENT', event])
|
||||
},
|
||||
close() {
|
||||
ws.close()
|
||||
|
||||
Reference in New Issue
Block a user