mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-19 19:46:42 +00:00
Fix subscription completion condition
This commit is contained in:
parent
9cc50e1894
commit
658911ce9f
@ -189,7 +189,17 @@ const request = (relays, filters, {threshold = 1} = {}): Promise<Record<string,
|
|||||||
const eose = []
|
const eose = []
|
||||||
|
|
||||||
const attemptToComplete = () => {
|
const attemptToComplete = () => {
|
||||||
if (eose.length >= threshold || Date.now() - now >= 5000) {
|
const done = (
|
||||||
|
eose.length === relays.length
|
||||||
|
|| eose.filter(url => relaysWithEvents.has(url)).length >= threshold
|
||||||
|
|| (
|
||||||
|
Date.now() - now >= 1000
|
||||||
|
&& eose.length > relays.length - Math.round(relays.length / 10)
|
||||||
|
)
|
||||||
|
|| Date.now() - now >= 5000
|
||||||
|
)
|
||||||
|
|
||||||
|
if (done) {
|
||||||
agg.unsub()
|
agg.unsub()
|
||||||
resolve(events)
|
resolve(events)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user