Nostr Relay Information in GoNostr (Notes and Other Stuff Transmitted by Relays) uses clients and relays, and where users run clients, and where anyone can be a relay. Users identify themselves with these public key, and every post to a relay is then signed. There is no communications between relays, and each relay only services its associated clients. A client then subscribes by posting their public key to the relay, and then receives updates in a chronological manner. With this, a user could be banned from a specific relay, but they can still post to other relays. Followers of a banned user, can then still follow them on another relay as their public key will not change. When a user is following someone, their recommendations for relays can then be added automatically to the user’s list of relays for querying. Someone who is leaving a relay can then publish a recommendation, so that their followers can follow them there. A user, too, can publish to one or more relays, and so the infrastructure is less easy to censor. A cost for publishing can also be integrated, and which can limit the spamming of a relay. Currently avaialable relays are shown [here]. . |
Theory
Nostr (Notes and Other Stuff Transmitted by Relays) uses clients and relays, and where users run clients, and where anyone can be a relay. Users identify themselves with these public key, and every post to a relay is then signed. There is no communications between relays, and each relay only services its associated clients. A client then subscribes by posting their public key to the relay, and then receives updates in a chronological manner. With this, a user could be banned from a specific relay, but they can still post to other relays. Followers of a banned user, can then still follow them on another relay as their public key will not change. When a user is following someone, their recommendations for relays can then be added automatically to the user’s list of relays for querying. Someone who is leaving a relay can then publish a recommendation, so that their followers can follow them there. A user, too, can publish to one or more relays, and so the infrastructure is less easy to censor. A cost for publishing can also be integrated, and which can limit the spamming of a relay.
We can create a request to a relay with:
ctx, _ := context.WithTimeout(context.Background(), 3*time.Second) // connect to relay url := "wss://relay.n057r.club" argCount := len(os.Args[1:]) if (argCount>0) {url= string(os.Args[1])} relay, err := nip11.Fetch(ctx, url)
Code
The following is some sample code:
package main import ( "context" "fmt" "time" "os" "github.com/nbd-wtf/go-nostr/nip11" ) func main() { ctx, _ := context.WithTimeout(context.Background(), 3*time.Second) // connect to relay url := "wss://relay.n057r.club" argCount := len(os.Args[1:]) if (argCount>0) {url= string(os.Args[1])} relay, err := nip11.Fetch(ctx, url) if err != nil { panic(err) } fmt.Printf("Name: %v\n",relay.Name) fmt.Printf("Description: %v\n",relay.Description) fmt.Printf("PubKey: %v\n",relay.PubKey) fmt.Printf("Contact: %v\n",relay.Contact) fmt.Printf("SupportedNIPs: %v\n",relay.SupportedNIPs) fmt.Printf("Software: %v\n",relay.Software) fmt.Printf("Version: %v\n",relay.Version) }
And a sample run is:
Name: wss://nostr.lu.ke Description: A superfast Nostr relay PubKey: bae77874946ec111f94be59aef282de092dc4baf213f8ecb8c9e15cb7ed7304e Contact: mailto:mail.lu.ke SupportedNIPs: [1 9 11 12 15 16 20 22] Software: git+https://github.com/hoytech/strfry.git Version: v103-e5ec135