mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 21:32:56 +01:00
some changes and fixes related to sub.Sub().
This commit is contained in:
parent
5f3221e966
commit
1f1d3cfe7f
@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func queryName(fullname string) string {
|
||||
func QueryIdentifier(fullname string) string {
|
||||
spl := strings.Split(fullname, "@")
|
||||
if len(spl) != 2 {
|
||||
return ""
|
||||
@ -30,3 +30,11 @@ func queryName(fullname string) string {
|
||||
pubkey, _ := result.Names[name]
|
||||
return pubkey
|
||||
}
|
||||
|
||||
func NormalizeIdentifier(fullname string) string {
|
||||
if strings.HasPrefix(fullname, "_@") {
|
||||
return fullname[2:]
|
||||
}
|
||||
|
||||
return fullname
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ func (r *RelayPool) Sub(filters Filters) *Subscription {
|
||||
random := make([]byte, 7)
|
||||
rand.Read(random)
|
||||
|
||||
subscription := Subscription{filters: filters}
|
||||
subscription := Subscription{}
|
||||
subscription.channel = hex.EncodeToString(random)
|
||||
subscription.relays = make(map[string]*Connection)
|
||||
for relay, policy := range r.Relays {
|
||||
@ -218,7 +218,7 @@ func (r *RelayPool) Sub(filters Filters) *Subscription {
|
||||
subscription.UniqueEvents = make(chan Event)
|
||||
r.subscriptions[subscription.channel] = &subscription
|
||||
|
||||
subscription.Sub()
|
||||
subscription.Sub(filters)
|
||||
return &subscription
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,9 @@ func (subscription Subscription) Unsub() {
|
||||
}
|
||||
}
|
||||
|
||||
func (subscription Subscription) Sub() {
|
||||
func (subscription *Subscription) Sub(filters Filters) {
|
||||
subscription.filters = filters
|
||||
|
||||
for _, conn := range subscription.relays {
|
||||
message := []interface{}{
|
||||
"REQ",
|
||||
|
Loading…
x
Reference in New Issue
Block a user