rust-nostr / nostr

Nostr protocol implementation, high-level client library, Nostr Wallet Connect, bindings and more.
https://rust-nostr.org/
MIT License
427 stars 95 forks source link

Gossip storage and relays rank/score #570

Open yukibtc opened 2 months ago

yukibtc commented 2 months ago
reyamir commented 1 month ago

I see a cons of current gossip method is the client is trying connect inbox/outbox relays before query event

// Add outbox relays
for url in broken_down.outbox_urls.into_iter() {
    if self.add_outbox_relay(&url).await? {
        self.connect_relay(url).await?;
    }
}

// Add inbox relays
for url in broken_down.inbox_urls.into_iter() {
    if self.add_inbox_relay(&url).await? {
        self.connect_relay(url).await?;
    }
}

If relay have some errors, client will try reconnect, the fetch events will become very slow. I wonder if when this issue is resolved (gossip storage and relays rank/score implemented). Will this problem be solved too?

yukibtc commented 1 month ago

If relay have some errors, client will try reconnect, the fetch events will become very slow.

Yes, this is true but after few attempts the SDK will start skipping unresponsive relays (this in general, not only for gossip). This require some secs so if the relay was just added it will not be skipped.

I wonder if when this issue is resolved (gossip storage and relays rank/score implemented). Will this problem be solved too?

Yeah, partially. I still have to study the best way to implement it. Using a relay score I can ignore the unresponsive relays but for new ones the issue could still persist (if the relays are new, never saw before).