mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
prevent a relay from eoseing then closing and causing pool handlers to fire twice.
This commit is contained in:
@@ -84,6 +84,7 @@ export class AbstractSimplePool {
|
|||||||
// batch all EOSEs into a single
|
// batch all EOSEs into a single
|
||||||
const eosesReceived: boolean[] = []
|
const eosesReceived: boolean[] = []
|
||||||
let handleEose = (i: number) => {
|
let handleEose = (i: number) => {
|
||||||
|
if (eosesReceived[i]) return // do not act twice for the same relay
|
||||||
eosesReceived[i] = true
|
eosesReceived[i] = true
|
||||||
if (eosesReceived.filter(a => a).length === relaysLength) {
|
if (eosesReceived.filter(a => a).length === relaysLength) {
|
||||||
params.oneose?.()
|
params.oneose?.()
|
||||||
@@ -93,6 +94,7 @@ export class AbstractSimplePool {
|
|||||||
// batch all closes into a single
|
// batch all closes into a single
|
||||||
const closesReceived: string[] = []
|
const closesReceived: string[] = []
|
||||||
let handleClose = (i: number, reason: string) => {
|
let handleClose = (i: number, reason: string) => {
|
||||||
|
if (closesReceived[i]) return // do not act twice for the same relay
|
||||||
handleEose(i)
|
handleEose(i)
|
||||||
closesReceived[i] = reason
|
closesReceived[i] = reason
|
||||||
if (closesReceived.filter(a => a).length === relaysLength) {
|
if (closesReceived.filter(a => a).length === relaysLength) {
|
||||||
|
|||||||
Reference in New Issue
Block a user