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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user