File tree Expand file tree Collapse file tree 3 files changed +41
-2
lines changed
Expand file tree Collapse file tree 3 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -107,13 +107,13 @@ func BenchmarkIDCheck(b *testing.B) {
107107 evt .Sign (GeneratePrivateKey ())
108108
109109 b .Run ("naïve" , func (b * testing.B ) {
110- for b . Loop () {
110+ for i := 0 ; i < b . N ; i ++ {
111111 _ = evt .GetID () == evt .ID
112112 }
113113 })
114114
115115 b .Run ("big brain" , func (b * testing.B ) {
116- for b . Loop () {
116+ for i := 0 ; i < b . N ; i ++ {
117117 _ = evt .CheckID ()
118118 }
119119 })
File renamed without changes.
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "context"
5+ "fmt"
6+
7+ "github.com/nbd-wtf/go-nostr"
8+ )
9+
10+ func main () {
11+ sk := nostr .GeneratePrivateKey ()
12+ pub , _ := nostr .GetPublicKey (sk )
13+ ev := nostr.Event {
14+ PubKey : pub ,
15+ CreatedAt : nostr .Now (),
16+ Kind : nostr .KindTextNote ,
17+ Tags : nil ,
18+ Content : "Hello Causality Graph!" ,
19+ }
20+
21+ // calling Sign sets the event ID field and the event Sig field
22+ ev .Sign (sk )
23+
24+ // publish the event to self relays
25+ ctx := context .Background ()
26+ for _ , url := range []string {"ws://161.97.129.166:10547" } {
27+ relay , err := nostr .RelayConnect (ctx , url )
28+ if err != nil {
29+ fmt .Println (err )
30+ continue
31+ }
32+ if err := relay .Publish (ctx , ev ); err != nil {
33+ fmt .Println (err )
34+ continue
35+ }
36+
37+ fmt .Printf ("published to %s\n " , url )
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments