Fix sync with dumb relays
This commit is contained in:
@@ -27,6 +27,14 @@ export const inc = (x: number | Nil) => (x || 0) + 1
|
||||
|
||||
export const dec = (x: number | Nil) => (x || 0) - 1
|
||||
|
||||
export const lt = (x: number | Nil, y: number | Nil) => (x || 0) < (y || 0)
|
||||
|
||||
export const lte = (x: number | Nil, y: number | Nil) => (x || 0) <= (y || 0)
|
||||
|
||||
export const gt = (x: number | Nil, y: number | Nil) => (x || 0) > (y || 0)
|
||||
|
||||
export const gte = (x: number | Nil, y: number | Nil) => (x || 0) >= (y || 0)
|
||||
|
||||
export const max = (xs: number[]) => xs.reduce((a, b) => Math.max(a, b), 0)
|
||||
|
||||
export const min = (xs: number[]) => xs.reduce((a, b) => Math.min(a, b), 0)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {ctx, groupBy, now, pushToMapKey, inc, flatten, chunk} from '@welshman/lib'
|
||||
import {ctx, assoc, lt, groupBy, now, pushToMapKey, inc, flatten, chunk} from '@welshman/lib'
|
||||
import type {SignedEvent, TrustedEvent, Filter} from '@welshman/util'
|
||||
import {subscribe} from './Subscribe'
|
||||
import {publish} from './Publish'
|
||||
@@ -168,9 +168,7 @@ export const pullWithoutNegentropy = async ({relays, filters, onEvent}: PullWith
|
||||
await new Promise<void>(resolve => {
|
||||
subscribe({
|
||||
relays,
|
||||
filters: filters
|
||||
.filter(filter => !filter.since || filter.since > until)
|
||||
.map(filter => ({...filter, until})),
|
||||
filters: filters.filter(f => lt(f.since, until)).map(assoc('until', until)),
|
||||
closeOnEose: true,
|
||||
onClose: () => {
|
||||
done = !anyResults
|
||||
|
||||
Reference in New Issue
Block a user