prevent a relay from eoseing then closing and causing pool handlers to fire twice.

This commit is contained in:
fiatjaf 2025-03-02 01:25:06 -03:00
parent 174d36a440
commit 97bded8f5b
1 changed files with 2 additions and 0 deletions

View File

@ -84,6 +84,7 @@ export class AbstractSimplePool {
// batch all EOSEs into a single
const eosesReceived: boolean[] = []
let handleEose = (i: number) => {
if (eosesReceived[i]) return // do not act twice for the same relay
eosesReceived[i] = true
if (eosesReceived.filter(a => a).length === relaysLength) {
params.oneose?.()
@ -93,6 +94,7 @@ export class AbstractSimplePool {
// batch all closes into a single
const closesReceived: string[] = []
let handleClose = (i: number, reason: string) => {
if (closesReceived[i]) return // do not act twice for the same relay
handleEose(i)
closesReceived[i] = reason
if (closesReceived.filter(a => a).length === relaysLength) {