Convert threshold to percentage

This commit is contained in:
Jonathan Staab 2023-02-08 09:10:12 -06:00
parent 0fd93bc461
commit e42c217f01
2 changed files with 4 additions and 5 deletions

View File

@ -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()

View File

@ -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}
})
)
}