I use nostr-tool and I just create a relay poll with all the relays that you want and then always use that pool.
#asknostr When publishing events to relays, what is the best practice if we are trying to publish to 10+ relays in terms of duplicate messages? For example, with Zap Receipts, I see "Create a nostr event of kind 9735 as described below, and publish it to the relays declared in the zap request." ... in our NWC implementation, we've seen that often there can be 10 or 20 relays "declared".
The most stable and lowest-latency way to do this, at least in my mind, is to try to connect to all of the relays, and then send to these relays after the first relay connects, after the 3rd relay connects, and then after about 80% of the relays have connected.
Because what is the alternative? Wait until all 20 relays connect !? That is going to be too slow, and probably at least 1 relay is down at any time! So we can't wait for all of them to connect!
Right now we've implemented this "wait for 1, wait for 3, wait for 80%" logic, but that means we are sending DUPLICATE Zap Receipts -- usually three in total!
At least in nostr:npub1yzvxlwp7wawed5vgefwfmugvumtp8c8t0etk3g8sky4n0ndvyxesnxrf8q , I find that it does show more than one zap receipt, even when there are duplicates, but if I refresh the page, then it seems to de-duplicate the zap receipts, so only one shows on the profile.
Discussion
I don't think that will work for Zap Receipts. For these receipts, the NWC provider must dynamically connect to an send messages the relays that are specified in the inbound message ... see here: https://github.com/nostr-protocol/nips/blob/master/57.md#appendix-a-zap-request-event .... so we can't know in advance which relays we're supposed to connect to... we need to dynamically connect to the relays depending on what the zap recipient specifies...
got it, I don't have experience in that scenario, but I think if you receive a list of relays you could create a pool with those relays and publish to all of them, that pool would be temporary I guess but I think it handles the connections for you.
Can you share more insights? How to access it? The purpose of using it?
I just use it like in the example :
https://github.com/nbd-wtf/nostr-tools?tab=readme-ov-file#interacting-with-multiple-relays