nostr-tools
Advanced tools
Comparing version 1.7.0 to 1.7.1
@@ -332,3 +332,4 @@ "use strict"; | ||
// relay.ts | ||
function relayInit(url) { | ||
function relayInit(url, options = {}) { | ||
let { listTimeout = 3e3, getTimeout = 3e3 } = options; | ||
var ws; | ||
@@ -507,3 +508,3 @@ var openSubs = {}; | ||
resolve(events); | ||
}, 1500); | ||
}, listTimeout); | ||
s.on("eose", () => { | ||
@@ -523,3 +524,3 @@ s.unsub(); | ||
resolve(null); | ||
}, 1500); | ||
}, getTimeout); | ||
s.on("event", (event) => { | ||
@@ -590,3 +591,6 @@ s.unsub(); | ||
return existing; | ||
const relay = relayInit(nm); | ||
const relay = relayInit(nm, { | ||
getTimeout: this.getTimeout * 0.9, | ||
listTimeout: this.getTimeout * 0.9 | ||
}); | ||
this._conn[nm] = relay; | ||
@@ -593,0 +597,0 @@ await relay.connect(); |
{ | ||
"name": "nostr-tools", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"description": "Tools for making a Nostr client.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -32,3 +32,6 @@ import {Relay, relayInit} from './relay' | ||
const relay = relayInit(nm) | ||
const relay = relayInit(nm, { | ||
getTimeout: this.getTimeout * 0.9, | ||
listTimeout: this.getTimeout * 0.9 | ||
}) | ||
this._conn[nm] = relay | ||
@@ -35,0 +38,0 @@ |
14
relay.ts
@@ -38,3 +38,11 @@ /* global WebSocket */ | ||
export function relayInit(url: string): Relay { | ||
export function relayInit( | ||
url: string, | ||
options: { | ||
getTimeout?: number | ||
listTimeout?: number | ||
} = {} | ||
): Relay { | ||
let {listTimeout = 3000, getTimeout = 3000} = options | ||
var ws: WebSocket | ||
@@ -256,3 +264,3 @@ var openSubs: {[id: string]: {filters: Filter[]} & SubscriptionOptions} = {} | ||
resolve(events) | ||
}, 1500) | ||
}, listTimeout) | ||
s.on('eose', () => { | ||
@@ -273,3 +281,3 @@ s.unsub() | ||
resolve(null) | ||
}, 1500) | ||
}, getTimeout) | ||
s.on('event', (event: Event) => { | ||
@@ -276,0 +284,0 @@ s.unsub() |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2097088
14230