mirror of
https://github.com/bitvora/wot-relay.git
synced 2025-06-06 18:31:05 +00:00
fix archiving
This commit is contained in:
parent
b762c1c974
commit
797c3d89b4
12
main.go
12
main.go
@ -219,18 +219,17 @@ func appendPubkey(pubkey string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func archiveTrustedNotes(relay *khatru.Relay, ctx context.Context) {
|
func archiveTrustedNotes(relay *khatru.Relay, ctx context.Context) {
|
||||||
ticker := time.NewTicker(10 * time.Minute)
|
ticker := time.NewTicker(1 * time.Minute)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
archivePool = nostr.NewSimplePool(ctx)
|
archivePool = nostr.NewSimplePool(ctx)
|
||||||
|
|
||||||
for range ticker.C {
|
for range ticker.C {
|
||||||
|
since := nostr.Timestamp(time.Now().Unix())
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
trustNetworkCopy := make([]string, len(trustNetwork))
|
trustNetworkCopy := make([]string, len(trustNetwork))
|
||||||
copy(trustNetworkCopy, trustNetwork)
|
copy(trustNetworkCopy, trustNetwork)
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
ctxTimeout, cancel := context.WithTimeout(ctx, 9*time.Minute)
|
|
||||||
// Create a new context with timeout for each iteration of the loop
|
|
||||||
|
|
||||||
filters := []nostr.Filter{{
|
filters := []nostr.Filter{{
|
||||||
Kinds: []int{
|
Kinds: []int{
|
||||||
@ -246,10 +245,11 @@ func archiveTrustedNotes(relay *khatru.Relay, ctx context.Context) {
|
|||||||
nostr.KindZap,
|
nostr.KindZap,
|
||||||
nostr.KindTextNote,
|
nostr.KindTextNote,
|
||||||
},
|
},
|
||||||
|
Since: &since,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
// Iterate over events from the pool and archive trusted notes
|
timeout, cancel := context.WithTimeout(ctx, 1*time.Minute)
|
||||||
for ev := range archivePool.SubManyEose(ctxTimeout, relays, filters) {
|
for ev := range archivePool.SubManyEose(timeout, relays, filters) {
|
||||||
for _, trustedPubkey := range trustNetworkCopy {
|
for _, trustedPubkey := range trustNetworkCopy {
|
||||||
if ev.Event.PubKey == trustedPubkey {
|
if ev.Event.PubKey == trustedPubkey {
|
||||||
if ev.Event.Kind == nostr.KindContactList {
|
if ev.Event.Kind == nostr.KindContactList {
|
||||||
@ -263,7 +263,5 @@ func archiveTrustedNotes(relay *khatru.Relay, ctx context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cancel()
|
cancel()
|
||||||
|
|
||||||
fmt.Println("archiveTrustedNotes: finished one cycle, will restart in 10 minutes")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user