···
type Set[T comparable] map[T]struct{}
type SubscriberData struct {
···
RepostURI string `json:"repost_uri"`
35
+
// storing the subscriber data in both Should Be Fine
36
+
// we dont modify subscriber data at the same time in two places
subscribers = hashmap.New[string, *SubscriberData]()
listeningTo = hashmap.New[string, *hashmap.Map[string, *SubscriberData]]()
···
52
-
func getFollowsDids() []string {
54
-
subscribers.Range(func(s string, sd *SubscriberData) bool {
55
-
for follow, _ := range sd.ListenTo {
56
-
dids = append(dids, follow)
func getSubscriberDids() []string {
dids := make([]string, 0, subscribers.Len())
subscribers.Range(func(s string, sd *SubscriberData) bool {
···
61
+
func listenTo(sd *SubscriberData, did string) {
62
+
targetDids, _ := listeningTo.GetOrInsert(did, hashmap.New[string, *SubscriberData]())
63
+
targetDids.Insert(sd.DID, sd)
66
+
func stopListeningTo(subscriberDid, did string) {
67
+
if targetDids, exists := listeningTo.Get(did); exists {
68
+
targetDids.Del(subscriberDid)
···
logger.Info("WebSocket connection closed", "error", err)
163
-
func listenTo(sd *SubscriberData, did string) {
164
-
targetDids, _ := listeningTo.GetOrInsert(did, hashmap.New[string, *SubscriberData]())
165
-
targetDids.Insert(sd.DID, sd)
168
-
func stopListeningTo(subscriberDid, did string) {
169
-
if targetDids, exists := listeningTo.Get(did); exists {
170
-
targetDids.Del(subscriberDid)