nostr package, readme updates accordingly, matching example program (#14)
This commit is contained in:
20
README.md
20
README.md
@@ -13,12 +13,8 @@ A set of useful things for [Nostr Protocol](https://github.com/fiatjaf/nostr) im
|
||||
```go
|
||||
pool := nostr.NewRelayPool()
|
||||
|
||||
pool.Add("wss://relay.nostr.com/", &nostr.RelayPoolPolicy{
|
||||
SimplePolicy: nostr.SimplePolicy{Read: true, Write: true},
|
||||
})
|
||||
pool.Add("wss://nostrrelay.example.com/", &nostr.RelayPoolPolicy{
|
||||
SimplePolicy: nostr.SimplePolicy{Read: true, Write: true},
|
||||
})
|
||||
pool.Add("wss://relay.nostr.com/", nostr.SimplePolicy{Read: true, Write: true})
|
||||
pool.Add("wss://nostrrelay.example.com/", nostr.SimplePolicy{Read: true, Write: true})
|
||||
|
||||
for notice := range pool.Notices {
|
||||
log.Printf("%s has sent a notice: '%s'\n", notice.Relay, notice.Message)
|
||||
@@ -28,10 +24,10 @@ for notice := range pool.Notices {
|
||||
### Listening for events
|
||||
|
||||
```go
|
||||
sub := pool.Sub(nostr.EventFilters{
|
||||
sub := pool.Sub(nostr.Filters{
|
||||
{
|
||||
Authors: []string{"0ded86bf80c76847320b16f22b7451c08169434837a51ad5fe3b178af6c35f5d"},
|
||||
Kinds: []string{nostr.KindTextNote}, // or {1}
|
||||
Kinds: []int{nostr.KindTextNote}, // or {1}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -53,7 +49,7 @@ secretKey := "3f06a81e0a0c2ad34ee9df2a30d87a810da9e3c3881f780755ace5e5e64d30a7"
|
||||
pool.SecretKey = &secretKey
|
||||
|
||||
event, statuses, _ := pool.PublishEvent(&nostr.Event{
|
||||
CreatedAt: uint32(time.Now().Unix()),
|
||||
CreatedAt: time.Now(),
|
||||
Kind: nostr.KindTextNote,
|
||||
Tags: make(nostr.Tags, 0),
|
||||
Content: "hello",
|
||||
@@ -83,3 +79,9 @@ sk, _ := nostr.GenerateKey()
|
||||
fmt.Println("sk:", sk)
|
||||
fmt.Println("pk:", nostr.GetPublicKey(sk))
|
||||
```
|
||||
|
||||
### Example Program
|
||||
|
||||
```
|
||||
go run example/example.go
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user