Skip to content

Assign multiples relays to Nostr::Client instance #13

Description

@TrumanBlurbank

What is the recommended way to publish a Nostr::Event to multiples relays ? Currently, it seems that Nostr::Client takes only one relay option which force to recreate the client for each relays in a loop as there is no possibility to set it later on the client instance.

Proposed enhancements:

  1. Allows an array of relays in Nostr::Client that would automatically connect and publish to each relays

    c = Nostr::Client.new(
     private_key: "XXX",
     relays: ["wss://nos.lol", "wss://other.relay"] # Not possible ❌
    )
    
    e = Nostr::Event.new(...)
    e = c.sign(e)
    
    c.connect
    c.publish(e)
    c.close
  2. Allows to set the relay later to keep only one client instance and assign relay in a loop

    c = Nostr::Client.new(
      private_key: "XXX"
    )
    e = Nostr::Event.new(...)
    e = c.sign(e)
     
    ALL_RELAYS.each do |relay|
      c.relay = relay # Not possible ❌     
      c.connect
      c.publish(e)
      c.close
    end

Solution 1 would be very elegant, what do you think ?
Thank you !

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions