mirror of
https://github.com/aljazceru/haven.git
synced 2026-01-12 18:14:22 +01:00
Merge pull request #3 from bitvora/dev-oomFixAttempt
put blastr in goroutines to prevent oom
This commit is contained in:
17
blastr.go
17
blastr.go
@@ -10,12 +10,15 @@ import (
|
||||
func blast(ev *nostr.Event) {
|
||||
ctx := context.Background()
|
||||
for _, relay := range config.BlastrRelays {
|
||||
log.Println("🔫 blasting to", relay)
|
||||
connect, err := nostr.RelayConnect(ctx, relay)
|
||||
if err != nil {
|
||||
log.Println("error connecting to relay", relay, err)
|
||||
continue
|
||||
}
|
||||
connect.Publish(ctx, *ev)
|
||||
go blastRoutine(ctx, relay, ev)
|
||||
}
|
||||
}
|
||||
|
||||
func blastRoutine(ctx context.Context, relay string, ev *nostr.Event) {
|
||||
connect, err := nostr.RelayConnect(ctx, relay)
|
||||
if err != nil {
|
||||
log.Println("error connecting to relay", relay, err)
|
||||
}
|
||||
connect.Publish(ctx, *ev)
|
||||
log.Println("🔫 blasted to", relay)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user