new context for each pull, no eose

This commit is contained in:
Barry Deen 2024-09-07 17:08:55 -04:00
parent a385e86bad
commit a97e0ab2d8

View File

@ -248,9 +248,10 @@ func archiveTrustedNotes(relay *khatru.Relay, ctx context.Context) {
ticker := time.NewTicker(1 * time.Minute) ticker := time.NewTicker(1 * time.Minute)
defer ticker.Stop() defer ticker.Stop()
archivePool = nostr.NewSimplePool(ctx)
for range ticker.C { for range ticker.C {
timeout, cancel := context.WithTimeout(ctx, 58*time.Second) ctx := context.Background()
archivePool = nostr.NewSimplePool(ctx)
timeout, cancel := context.WithTimeout(ctx, 50*time.Second)
filters := []nostr.Filter{{ filters := []nostr.Filter{{
Kinds: []int{ Kinds: []int{
nostr.KindArticle, nostr.KindArticle,
@ -268,6 +269,7 @@ func archiveTrustedNotes(relay *khatru.Relay, ctx context.Context) {
}} }}
nKeys := uint64(len(trustNetwork)) nKeys := uint64(len(trustNetwork))
fmt.Println("trust network size:", nKeys)
bloomFilter := blobloom.NewOptimized(blobloom.Config{ bloomFilter := blobloom.NewOptimized(blobloom.Config{
Capacity: nKeys, Capacity: nKeys,
FPRate: 1e-4, FPRate: 1e-4,
@ -276,7 +278,7 @@ func archiveTrustedNotes(relay *khatru.Relay, ctx context.Context) {
bloomFilter.Add(xxhash.Sum64([]byte(trustedPubkey))) bloomFilter.Add(xxhash.Sum64([]byte(trustedPubkey)))
} }
for ev := range archivePool.SubManyEose(timeout, relays, filters) { for ev := range archivePool.SubMany(timeout, relays, filters) {
if bloomFilter.Has(xxhash.Sum64([]byte(ev.Event.PubKey))) { if bloomFilter.Has(xxhash.Sum64([]byte(ev.Event.PubKey))) {
if len(ev.Event.Tags) > 2000 { if len(ev.Event.Tags) > 2000 {