mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-10-09 20:33:27 +02:00
Update relay.go
This commit is contained in:
committed by
fiatjaf
parent
d7d4c62602
commit
a16e2a28d5
6
relay.go
6
relay.go
@@ -197,7 +197,7 @@ func (r *Relay) Connect(ctx context.Context) error {
|
|||||||
// Publish sends an "EVENT" command to the relay r as in NIP-01.
|
// Publish sends an "EVENT" command to the relay r as in NIP-01.
|
||||||
// Status can be: success, failed, or sent (no response from relay before ctx times out).
|
// Status can be: success, failed, or sent (no response from relay before ctx times out).
|
||||||
func (r *Relay) Publish(ctx context.Context, event Event) Status {
|
func (r *Relay) Publish(ctx context.Context, event Event) Status {
|
||||||
status := PublishStatusFailed
|
status := PublishStatusSent
|
||||||
|
|
||||||
// data races on status variable without this mutex
|
// data races on status variable without this mutex
|
||||||
var mu sync.Mutex
|
var mu sync.Mutex
|
||||||
@@ -230,10 +230,6 @@ func (r *Relay) Publish(ctx context.Context, event Event) Status {
|
|||||||
|
|
||||||
// publish event
|
// publish event
|
||||||
if err := r.Connection.WriteJSON([]interface{}{"EVENT", event}); err != nil {
|
if err := r.Connection.WriteJSON([]interface{}{"EVENT", event}); err != nil {
|
||||||
// update status (this will be returned later)
|
|
||||||
mu.Lock()
|
|
||||||
status = PublishStatusSent
|
|
||||||
mu.Unlock()
|
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user