PublishEvent() fixes.

This commit is contained in:
fiatjaf
2022-11-17 09:28:45 -03:00
parent 381ee2cc01
commit 480ee0ef87
3 changed files with 10 additions and 4 deletions
+6 -1
View File
@@ -149,7 +149,12 @@ func Unique(all chan EventMessage) chan Event {
}
func (r *RelayPool) PublishEvent(evt *Event) (*Event, chan PublishStatus, error) {
status := make(chan PublishStatus, 1)
size := 0
r.Relays.Range(func(_ string, _ *Relay) bool {
size++
return true
})
status := make(chan PublishStatus, size)
if r.SecretKey == nil && (evt.PubKey == "" || evt.Sig == "") {
return nil, status, errors.New("PublishEvent needs either a signed event to publish or to have been configured with a .SecretKey.")