mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-07 07:26:48 +00:00
exchanges/websocket: update websocket rate limiting to use requester rate limiting functionality (#1578)
* exchanges/websocket: update websocket rate limiting to use requester rate limiting functionality. * glorious: nits * rm unsused * updoo * glorious: purgerino * reduce duplicate code * thrasher: engrish --------- Co-authored-by: shazbert <ryan.oharareid@thrasher.io>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package bithumb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@@ -203,7 +204,7 @@ func (b *Bithumb) Subscribe(channelsToSubscribe subscription.List) error {
|
||||
if s.Channel == "ticker" {
|
||||
req.TickTypes = wsDefaultTickTypes
|
||||
}
|
||||
err := b.Websocket.Conn.SendJSONMessage(req)
|
||||
err := b.Websocket.Conn.SendJSONMessage(context.TODO(), req)
|
||||
if err == nil {
|
||||
err = b.Websocket.AddSuccessfulSubscriptions(s)
|
||||
}
|
||||
|
||||
@@ -32,8 +32,6 @@ import (
|
||||
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
|
||||
)
|
||||
|
||||
const wsRateLimitMillisecond = 1000
|
||||
|
||||
var errNotEnoughPairs = errors.New("at least one currency is required to fetch order history")
|
||||
|
||||
// SetDefaults sets the basic defaults for Bithumb
|
||||
@@ -172,7 +170,7 @@ func (b *Bithumb) Setup(exch *config.Exchange) error {
|
||||
return b.Websocket.SetupNewConnection(stream.ConnectionSetup{
|
||||
ResponseCheckTimeout: exch.WebsocketResponseCheckTimeout,
|
||||
ResponseMaxLimit: exch.WebsocketResponseMaxLimit,
|
||||
RateLimit: wsRateLimitMillisecond,
|
||||
RateLimit: request.NewWeightedRateLimitByDuration(time.Second),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user