Replying to Avatar Five

Hey nostr:nprofile1qqsx3kq3vkgczq9hmfplc28h687py42yvms3zkyxh8nmkvn0vhkyyuspz4mhxue69uhkummnw3ezummcw3ezuer9wchsz9thwden5te0wfjkccte9ejxzmt4wvhxjme0qy88wumn8ghj7mn0wvhxcmmv9u0uehfp and #rust-nostr fans, can you enlighten me please:

When I am calculating my Web of Trust I do the following:

0. Create client with outbox model enabled

1. Get my follows, mutes, reports in one fetch call

2. Get follows, mutes, reports of my follows in another fetch call, using an authors filter that has all follows in it

3. Calculate scores with my weights locally

Question:

Why did step 2. take hours to complete?

It seems like it's trying to connect to loads of relays.

My guess is either I am doing sth horribly wrong or there is no smart relay set calculation for filters in the pool.

In ndk this calculation takes under 10 seconds to complete, even without any caching. It will first look at the filters and calculate a relay set that has all authors in it then does the fetching.

#asknostr #rust

Currently, when gossip is enabled, are used all relays in user lists (there isn't a relays score at the moment). This will be improved in the next versions where will be kept a relays and gossip state into the database.

But anyway, it's weird that it require hours to complete. Can you share a code example?

Reply to this note

Please Login to reply.

Discussion

Oh ok, I'll try that tomorrow, thanks !

I see you set connection timeout is 4s here https://github.com/Pleb5/muse/blob/16172fab3fd8e8cd4c2fe1036208b1d06ebec234/src/config.rs#L11C1-L11C71

If gossip enabled, client will wait for 4s before connect to relay, therefore everything will become super slow.

You can use `stream_events` instead of `fetch_events`, then query will be faster because client won't wait for all relays return EOSE.

Either way I need the whole result to calculate web of trust and then perhaps save to file.

There is no front-end reactivity necessary for this step

Maybe related to `connection_timeout` in client opts. If you set it some X value, client will try to connect to relay after X timeout pass, instead of stop trying connect after X timeout.

Okay tried your fix and it completed under 20 secs!

Thanks a lot!

The timeout in this case means "try to connect to the relays and wait for the connection for X seconds at most".