From 10b2e071d6c74c88a32cb024cd5f844da6fc131e Mon Sep 17 00:00:00 2001 From: Barry Deen Date: Thu, 12 Sep 2024 11:06:57 -0400 Subject: [PATCH] refresh profiles of the trust network --- main.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/main.go b/main.go index e58c6c6..5a23a7f 100644 --- a/main.go +++ b/main.go @@ -206,6 +206,31 @@ func updateTrustNetworkFilter() { } } +func refreshProfiles(ctx context.Context, relay *khatru.Relay) { + mu.Lock() + defer mu.Unlock() + + for i := 0; i < len(trustNetwork); i += 200 { + timeout, cancel := context.WithTimeout(ctx, 4*time.Second) + defer cancel() + + end := i + 200 + if end > len(trustNetwork) { + end = len(trustNetwork) + } + + filters := []nostr.Filter{{ + Authors: trustNetwork[i:end], + Kinds: []int{nostr.KindProfileMetadata}, + }} + + for ev := range pool.SubManyEose(timeout, seedRelays, filters) { + relay.AddEvent(ctx, ev.Event) + log.Println("👤 profile updated: ", ev.Event.PubKey) + } + } +} + func refreshTrustNetwork(relay *khatru.Relay, ctx context.Context) { runTrustNetworkRefresh := func() { @@ -315,6 +340,7 @@ func appendOneHopNetwork(pubkey string) { func archiveTrustedNotes(relay *khatru.Relay, ctx context.Context) { timeout := time.After(time.Duration(config.RefreshInterval) * time.Hour) + go refreshProfiles(ctx, relay) filters := []nostr.Filter{{ Kinds: []int{