Skip to content

Commit

Permalink
normalize maker
Browse files Browse the repository at this point in the history
  • Loading branch information
ngocthanh1389 committed Jul 4, 2024
1 parent 367ec9d commit 590f08c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/server/tradelogs/broadcaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package server

import (
"fmt"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -68,6 +69,7 @@ func (b *Broadcaster) Test() {
func (b *Broadcaster) removeConn(conn *websocket.Conn, id, event, maker string) {
b.mu.Lock()
defer b.mu.Unlock()
maker = strings.ToLower(maker)
e, ok := b.clients[fmt.Sprintf("%s-%s", event, maker)]
if !ok {
return
Expand All @@ -79,6 +81,7 @@ func (b *Broadcaster) removeConn(conn *websocket.Conn, id, event, maker string)
func (b *Broadcaster) addConn(conn *websocket.Conn, id, event, maker string) {
b.mu.Lock()
defer b.mu.Unlock()
maker = strings.ToLower(maker)
cons, ok := b.clients[combine(event, maker)]
if !ok {
cons = map[string]Con{}
Expand All @@ -95,7 +98,8 @@ func (b *Broadcaster) addConn(conn *websocket.Conn, id, event, maker string) {
func (b *Broadcaster) writeEvent(log storage.TradeLog) {
b.mu.Lock()
defer b.mu.Unlock()
cons := b.clients[combine(log.EventHash, log.Maker)]
maker := strings.ToLower(log.Maker)
cons := b.clients[combine(log.EventHash, maker)]
for _, c := range cons {
if err := c.ws.WriteJSON(log); err != nil {
b.l.Errorw("error when send msg", "err", err)
Expand Down

0 comments on commit 590f08c

Please sign in to comment.