mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-30 15:10:40 +00:00
websocket: Remove GenerateMessageID (#2008)
* Exchanges: Remove example BespokeGenerateMessageID * Okx: Replace conn.RequestIDGenerator with MesssageID Continued overall direction to remove the closed-loop of e => conn => e roundtrip for message ids * Exchanges: Add MessageSequence This method removes the either/or nature of message id generation. We don't tie the message ids to connections, or to anything. Consumers just call whichever they want, or even combine them as they want. Anything more complicated will need a separate installation anyway * GateIO: Split usage of MessageID and MessageSequence * Binance: Switch to UUID message IDs * Kraken: Switch to e.MessageSequence * Kucoin: Switch to MessageID * HitBTC: Switch to UUIDv7 for ws message ID * Bybit: Switch to UUIDv7 for ws message ID * Bitfinex: Switch to UUIDv7 and MessageSequence Tested CID - It accepts 53 bits only for an int, so MessageSequence makes sense. Can't use MessageID * Websocket: Remove now unused MessageID function Moved all MessageID usage into funcs and onto base methods, to remove the closed loop of message IDs * Docs: Update guidance for message signatures
This commit is contained in:
@@ -1716,7 +1716,7 @@ func (e *Exchange) subscribeToChan(ctx context.Context, subs subscription.List)
|
||||
|
||||
// subId is a single round-trip identifier that provides linking sub requests to chanIDs
|
||||
// Although docs only mention subId for wsBookChannel, it works for all chans
|
||||
subID := strconv.FormatInt(e.Websocket.Conn.GenerateMessageID(false), 10)
|
||||
subID := e.MessageID()
|
||||
req["subId"] = subID
|
||||
|
||||
// Add a temporary Key so we can find this Sub when we get the resp without delay or context switch
|
||||
@@ -1829,7 +1829,7 @@ func (e *Exchange) WsSendAuth(ctx context.Context) error {
|
||||
|
||||
// WsNewOrder authenticated new order request
|
||||
func (e *Exchange) WsNewOrder(ctx context.Context, data *WsNewOrderRequest) (string, error) {
|
||||
data.CustomID = e.Websocket.AuthConn.GenerateMessageID(false)
|
||||
data.CustomID = e.MessageSequence()
|
||||
req := makeRequestInterface(wsOrderNew, data)
|
||||
resp, err := e.Websocket.AuthConn.SendMessageReturnResponse(ctx, request.Unset, data.CustomID, req)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user