refactor: align variable naming and add Binance time sync

1. Rename `traderRecord` to `trader` in handleCreateTrader
   - Aligns with upstream naming convention (nofxaios/dev)
   - Line 403: variable definition
   - Line 424: CreateTrader call

2. Add Binance server time synchronization (PR #145 simple fix)
   - Fixes timestamp errors (code=-1021)
   - Sets UseTestnet=false (ensure production network)
   - Syncs server time on trader initialization
   - Based on commit 64299c1 from pr-145 branch

Both changes improve compatibility with upstream and prevent
timestamp-related API failures.
This commit is contained in:
ZhouYongyou
2025-11-03 21:03:55 +08:00
parent a29eea2742
commit 7f87478ee1
2 changed files with 7 additions and 2 deletions

View File

@@ -400,7 +400,7 @@ func (s *Server) handleCreateTrader(c *gin.Context) {
}
// 创建交易员配置(数据库实体)
traderRecord := &config.TraderRecord{
trader := &config.TraderRecord{
ID: traderID,
UserID: userID,
Name: req.Name,
@@ -421,7 +421,7 @@ func (s *Server) handleCreateTrader(c *gin.Context) {
}
// 保存到数据库
err = s.database.CreateTrader(traderRecord)
err = s.database.CreateTrader(trader)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": fmt.Sprintf("创建交易员失败: %v", err)})
return