mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-19 11:43:35 +00:00
Convert threshold to percentage
This commit is contained in:
parent
0fd93bc461
commit
e42c217f01
@ -181,10 +181,10 @@ const subscribe = async (relays, filters, {onEvent, onEose}: Record<string, (e:
|
||||
}
|
||||
}
|
||||
|
||||
const request = (relays, filters, {threshold = 2} = {}): Promise<Record<string, unknown>[]> => {
|
||||
const request = (relays, filters, {threshold = 0.5} = {}): Promise<Record<string, unknown>[]> => {
|
||||
return new Promise(async resolve => {
|
||||
relays = uniqBy(prop('url'), relays.filter(r => isRelay(r.url)))
|
||||
threshold = Math.min(relays.length, threshold)
|
||||
threshold = relays.length * threshold
|
||||
|
||||
const now = Date.now()
|
||||
const relaysWithEvents = new Set()
|
||||
|
@ -37,7 +37,7 @@ const load = async (relays, pubkey) => {
|
||||
const events = await _load(
|
||||
relays,
|
||||
{kinds: [1, 7], '#p': [pubkey], since, limit: 1000},
|
||||
{threshold: 10}
|
||||
{threshold: 0.9}
|
||||
)
|
||||
|
||||
onChunk(relays, pubkey, events)
|
||||
@ -53,8 +53,7 @@ const listen = async (relays, pubkey) => {
|
||||
{kinds: [1, 7], '#p': [pubkey], since: now()},
|
||||
batch(300, events => {
|
||||
onChunk(relays, pubkey, events)
|
||||
}),
|
||||
{threshold: 2}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user