primitive support for CLOSED in SimplePool.

This commit is contained in:
fiatjaf
2023-12-01 13:37:24 -03:00
parent 775821f4e5
commit 711db062a1

View File

@@ -3,6 +3,7 @@ package nostr
import ( import (
"context" "context"
"fmt" "fmt"
"log"
"sync" "sync"
"time" "time"
@@ -116,6 +117,9 @@ func (pool *SimplePool) subMany(ctx context.Context, urls []string, filters Filt
} }
} }
case events <- IncomingEvent{Event: evt, Relay: relay}: case events <- IncomingEvent{Event: evt, Relay: relay}:
case reason := <-sub.ClosedReason:
log.Printf("CLOSED from %s: '%s'\n", nm, reason)
return
case <-ctx.Done(): case <-ctx.Done():
return return
} }
@@ -177,6 +181,9 @@ func (pool *SimplePool) subManyEose(ctx context.Context, urls []string, filters
return return
case <-sub.EndOfStoredEvents: case <-sub.EndOfStoredEvents:
return return
case reason := <-sub.ClosedReason:
log.Printf("CLOSED from %s: '%s'\n", nm, reason)
return
case evt, more := <-sub.Events: case evt, more := <-sub.Events:
if !more { if !more {
return return