mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-16 17:12:25 +08:00
perf: reuse shared HTTP client in Hyperliquid trader
Previously each direct API call (orders, sync, account) created a new http.Client, preventing TCP/TLS connection reuse. Now all calls share a single client on the HyperliquidTrader struct (30s timeout).
This commit is contained in:
@@ -217,7 +217,7 @@ func (t *HyperliquidTrader) getXYZDexBalance() (accountValue float64, unrealized
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
client := &http.Client{Timeout: 30 * time.Second}
|
||||
client := t.httpClient
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return 0, 0, nil, fmt.Errorf("failed to execute request: %w", err)
|
||||
@@ -308,7 +308,7 @@ func (t *HyperliquidTrader) getXyzMarketPrice(coin string) (float64, error) {
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
client := &http.Client{Timeout: 30 * time.Second}
|
||||
client := t.httpClient
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to execute request: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user