Fix concurrent map read/write race condition in MarketData

Add sync.RWMutex to protect future and spot price maps accessed by
WebSocket handlers (writers) and Telegram bot handlers (readers).
Also adds Alpha token support with caching.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-25 00:15:22 +07:00
parent 248d3153e7
commit 440fa3bacd
9 changed files with 297 additions and 31 deletions
+10 -2
View File
@@ -1,10 +1,11 @@
package binancex
import (
"strings"
"me.thuanle/bbot/internal/configs/binance"
"me.thuanle/bbot/internal/data"
"me.thuanle/bbot/internal/utils/stringx"
"strings"
)
func Symbol2Token(sym string) string {
@@ -74,7 +75,14 @@ func Token2Symbols(token string) []string {
}
func IsToken(s string) bool {
return len(Token2Symbols(s)) > 0
// First check regular symbols
if len(Token2Symbols(s)) > 0 {
return true
}
// Then check Alpha tokens
s = strings.ToUpper(s)
return data.Market.IsAlphaToken(s)
}
// Future2SpotSymbol convert future symbol to spot symbol