move everything to the same directory.
This commit is contained in:
@@ -9,13 +9,13 @@ A set of useful things for [Nostr Protocol](https://github.com/fiatjaf/nostr) im
|
||||
### Subscribing to a set of relays
|
||||
|
||||
```go
|
||||
pool := relaypool.New()
|
||||
pool := nostr.NewRelayPool()
|
||||
|
||||
pool.Add("wss://relay.nostr.com/", &relaypool.Policy{
|
||||
SimplePolicy: relaypool.SimplePolicy{Read: true, Write: true},
|
||||
pool.Add("wss://relay.nostr.com/", &nostr.RelayPoolPolicy{
|
||||
SimplePolicy: nostr.SimplePolicy{Read: true, Write: true},
|
||||
})
|
||||
pool.Add("wss://nostrrelay.example.com/", &relaypool.Policy{
|
||||
SimplePolicy: relaypool.SimplePolicy{Read: true, Write: true},
|
||||
pool.Add("wss://nostrrelay.example.com/", &nostr.RelayPoolPolicy{
|
||||
SimplePolicy: nostr.SimplePolicy{Read: true, Write: true},
|
||||
})
|
||||
|
||||
for notice := range pool.Notices {
|
||||
@@ -26,11 +26,10 @@ for notice := range pool.Notices {
|
||||
### Listening for events
|
||||
|
||||
```go
|
||||
kind1 := event.KindTextNote
|
||||
sub := pool.Sub(filter.EventFilters{
|
||||
sub := pool.Sub(nostr.EventFilters{
|
||||
{
|
||||
Authors: []string{"0ded86bf80c76847320b16f22b7451c08169434837a51ad5fe3b178af6c35f5d"},
|
||||
Kind: &kind1, // or 1
|
||||
Kinds: []string{nostr.KindTextNote}, // or {1}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -51,10 +50,10 @@ secretKey := "3f06a81e0a0c2ad34ee9df2a30d87a810da9e3c3881f780755ace5e5e64d30a7"
|
||||
|
||||
pool.SecretKey = &secretKey
|
||||
|
||||
event, statuses, _ := pool.PublishEvent(&event.Event{
|
||||
event, statuses, _ := pool.PublishEvent(&nostr.Event{
|
||||
CreatedAt: uint32(time.Now().Unix()),
|
||||
Kind: 1, // or event.KindTextNote
|
||||
Tags: make(event.Tags, 0),
|
||||
Kind: nostr.KindTextNote,
|
||||
Tags: make(nostr.Tags, 0),
|
||||
Content: "hello",
|
||||
})
|
||||
|
||||
@@ -64,11 +63,11 @@ log.Print(event.Sig)
|
||||
|
||||
for status := range statuses {
|
||||
switch status.Status {
|
||||
case relaypool.PublishStatusSent:
|
||||
case nostr.PublishStatusSent:
|
||||
fmt.Printf("Sent event %s to '%s'.\n", event.ID, status.Relay)
|
||||
case relaypool.PublishStatusFailed:
|
||||
case nostr.PublishStatusFailed:
|
||||
fmt.Printf("Failed to send event %s to '%s'.\n", event.ID, status.Relay)
|
||||
case relaypool.PublishStatusSucceeded:
|
||||
case nostr.PublishStatusSucceeded:
|
||||
fmt.Printf("Event seen %s on '%s'.\n", event.ID, status.Relay)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user