Yes, given varying performance levels for relays it should probably assign each relay a weight. (Haven’t read the links yet, just woke up)
Discussion
It’s deceptively complex to do it optimally - but good enough works ok too. Which relays you receive from differs, even by kinds you want, and publishing is similar complex.
Not sure if helpful, but a dump of my notes below around relay selection. Trying to end up with a diagram and list of functions that explain what logic to apply when and how to pick and prioritise relays.
Paid relays, rate limiting, kind, destination pubkeys, your preferences, relay hints, proof of work, parent events, mentioned pubkeys, etc — all can factor in. Relay health/connectivity.
——
getBestOutboundRelayForEvent
(Note: A paid relay filter should apply unless you have paid)
Kind 0/3/10_002
Maximally broadcast
Publish to Metadata Indexer Relays
Note (without reply or mention)
Do you want to maximally target your followers?
Do you want to maximally broadcast?
Reaction
Include parent relay hints (if provided)
getBestOutboundRelayForPubkey(author)
Repost
Include parent relay hints (if provided)
getBestOutboundRelayForPubkey(author)
Do you want to maximally target your followers?
Do you want to maximally broadcast?
Reply
Include parent relay hints (if provided)
getBestOutboundRelayForPubkey(author)
Do you want to maximally target your followers?
Do you want to maximally broadcast?
Reply + Mention
Include parent relay hints (if provided)
getBestOutboundRelayForPubkey(mention) for each mention
Mention
getBestOutboundRelayForPubkey(mention) for each mention
DM
getBestOutboundRelayForPubkey(recipient)
Event Report
? Broadcast or targeted relays ?
Long form Content
? Broadcast or targeted relays
(Nostr-connect)
?
(Zap Service Provider)
?
getBestOutboundRelayForPubkey
Kind 10_002
NIP05
Kind3 (or EOL?)
Fallback to my Publish/Write relays (as they can query them for lookup)
----------------------------
getBestQueryRelayForPubkey
getBestQueryRelayForEvent Id
If only an event Id is known.. Shotgun query / your read relays
getBestQueryRelayForEvent
Include event relay hints (if provided)
Check parent event (if known) relay hints
getBestQueryRelayForPubkey for each known thread participant
Other considerations
Min POW Required
Rate Limiting
This is a super interesting problem
Yep. The gossip model was effectively my initial approach too, for an unreleased relay recommendation engine, before I realised it was more complex. My approach was data driven, so basically which relays saw a pubkey’s 200 most recent events, rather than based on the kind 10002 pubkey relay manifest approach.
Basically similar to what you mentioned above, with a N coverage threshold and M max desired relays.