mirror of
https://github.com/bitvora/wot-relay.git
synced 2025-06-06 18:31:05 +00:00
Merge pull request #10 from bitvora/dev-stabilityFixCtx
new context for each pull, no eose
This commit is contained in:
commit
6ccb91e652
8
main.go
8
main.go
@ -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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user