mirror of
https://github.com/bitvora/wot-relay.git
synced 2025-06-06 18:31:05 +00:00
remove mutex and reduce logging
This commit is contained in:
parent
10b2e071d6
commit
a4116a31f9
22
main.go
22
main.go
@ -106,7 +106,6 @@ func main() {
|
|||||||
return true, "you are not in the web of trust"
|
return true, "you are not in the web of trust"
|
||||||
})
|
})
|
||||||
|
|
||||||
mu.Lock()
|
|
||||||
seedRelays = []string{
|
seedRelays = []string{
|
||||||
"wss://nos.lol",
|
"wss://nos.lol",
|
||||||
"wss://nostr.mom",
|
"wss://nostr.mom",
|
||||||
@ -123,7 +122,6 @@ func main() {
|
|||||||
"wss://nostrue.com",
|
"wss://nostrue.com",
|
||||||
"wss://relay.siamstr.com",
|
"wss://relay.siamstr.com",
|
||||||
}
|
}
|
||||||
mu.Unlock()
|
|
||||||
|
|
||||||
go refreshTrustNetwork(relay, ctx)
|
go refreshTrustNetwork(relay, ctx)
|
||||||
|
|
||||||
@ -192,9 +190,6 @@ func getEnv(key string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func updateTrustNetworkFilter() {
|
func updateTrustNetworkFilter() {
|
||||||
trustNetworkFilterMu.Lock()
|
|
||||||
defer trustNetworkFilterMu.Unlock()
|
|
||||||
|
|
||||||
nKeys := uint64(len(trustNetwork))
|
nKeys := uint64(len(trustNetwork))
|
||||||
log.Println("🌐 updating trust network filter with", nKeys, "keys")
|
log.Println("🌐 updating trust network filter with", nKeys, "keys")
|
||||||
trustNetworkFilter = blobloom.NewOptimized(blobloom.Config{
|
trustNetworkFilter = blobloom.NewOptimized(blobloom.Config{
|
||||||
@ -207,9 +202,6 @@ func updateTrustNetworkFilter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func refreshProfiles(ctx context.Context, relay *khatru.Relay) {
|
func refreshProfiles(ctx context.Context, relay *khatru.Relay) {
|
||||||
mu.Lock()
|
|
||||||
defer mu.Unlock()
|
|
||||||
|
|
||||||
for i := 0; i < len(trustNetwork); i += 200 {
|
for i := 0; i < len(trustNetwork); i += 200 {
|
||||||
timeout, cancel := context.WithTimeout(ctx, 4*time.Second)
|
timeout, cancel := context.WithTimeout(ctx, 4*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@ -226,8 +218,8 @@ func refreshProfiles(ctx context.Context, relay *khatru.Relay) {
|
|||||||
|
|
||||||
for ev := range pool.SubManyEose(timeout, seedRelays, filters) {
|
for ev := range pool.SubManyEose(timeout, seedRelays, filters) {
|
||||||
relay.AddEvent(ctx, ev.Event)
|
relay.AddEvent(ctx, ev.Event)
|
||||||
log.Println("👤 profile updated: ", ev.Event.PubKey)
|
|
||||||
}
|
}
|
||||||
|
log.Println("👤 profiles fetched:", end)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,8 +285,6 @@ func refreshTrustNetwork(relay *khatru.Relay, ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func appendRelay(relay string) {
|
func appendRelay(relay string) {
|
||||||
mu.Lock()
|
|
||||||
defer mu.Unlock()
|
|
||||||
|
|
||||||
for _, r := range relays {
|
for _, r := range relays {
|
||||||
if r == relay {
|
if r == relay {
|
||||||
@ -305,9 +295,6 @@ func appendRelay(relay string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func appendPubkey(pubkey string) {
|
func appendPubkey(pubkey string) {
|
||||||
mu.Lock()
|
|
||||||
defer mu.Unlock()
|
|
||||||
|
|
||||||
for _, pk := range trustNetwork {
|
for _, pk := range trustNetwork {
|
||||||
if pk == pubkey {
|
if pk == pubkey {
|
||||||
return
|
return
|
||||||
@ -322,9 +309,6 @@ func appendPubkey(pubkey string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func appendOneHopNetwork(pubkey string) {
|
func appendOneHopNetwork(pubkey string) {
|
||||||
mu.Lock()
|
|
||||||
defer mu.Unlock()
|
|
||||||
|
|
||||||
for _, pk := range oneHopNetwork {
|
for _, pk := range oneHopNetwork {
|
||||||
if pk == pubkey {
|
if pk == pubkey {
|
||||||
return
|
return
|
||||||
@ -362,9 +346,6 @@ func archiveTrustedNotes(relay *khatru.Relay, ctx context.Context) {
|
|||||||
var trustedNotes uint64
|
var trustedNotes uint64
|
||||||
var untrustedNotes uint64
|
var untrustedNotes uint64
|
||||||
|
|
||||||
trustNetworkFilterMu.Lock()
|
|
||||||
defer trustNetworkFilterMu.Unlock()
|
|
||||||
|
|
||||||
eventChan := pool.SubMany(ctx, seedRelays, filters)
|
eventChan := pool.SubMany(ctx, seedRelays, filters)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@ -392,7 +373,6 @@ func archiveTrustedNotes(relay *khatru.Relay, ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
relay.AddEvent(ctx, ev.Event)
|
relay.AddEvent(ctx, ev.Event)
|
||||||
log.Println("📦 archived note: ", ev.Event.ID)
|
|
||||||
trustedNotes++
|
trustedNotes++
|
||||||
} else {
|
} else {
|
||||||
untrustedNotes++
|
untrustedNotes++
|
||||||
|
Loading…
x
Reference in New Issue
Block a user