Refactor goroutine sleep order

This commit is contained in:
dd dd 2024-08-02 00:42:26 +02:00
parent 2ccb01f1f3
commit 16277358fe

View File

@ -13,19 +13,16 @@ func (e *Exit) announceExitNode(ctx context.Context) error {
if !e.config.Public { if !e.config.Public {
return nil return nil
} }
go func() { go func() {
for { for {
time.Sleep(time.Second * 10)
// create update event
// create a event
event := nostr.Event{ event := nostr.Event{
PubKey: e.publicKey, PubKey: e.publicKey,
CreatedAt: nostr.Now(), CreatedAt: nostr.Now(),
Kind: nostr.KindTextNote, Kind: nostr.KindTextNote,
Content: "", Tags: nostr.Tags{
Tags: nostr.Tags{nostr.Tag{"n", "nws"}, nostr.Tag{"expiration", strconv.FormatInt(time.Now().Add(time.Second*10).Unix(), 20)}}, nostr.Tag{"n", "nws"},
nostr.Tag{"expiration", strconv.FormatInt(time.Now().Add(time.Second*10).Unix(), 20)},
},
} }
err := event.Sign(e.config.NostrPrivateKey) err := event.Sign(e.config.NostrPrivateKey)
@ -41,9 +38,9 @@ func (e *Exit) announceExitNode(ctx context.Context) error {
// do not return here, try to publish the event to other relays // do not return here, try to publish the event to other relays
} }
} }
time.Sleep(time.Second * 10)
} }
}() }()
return nil return nil
} }