exchanges/GateIO, OKX: Fix and optimise websocket request ID message generation (#2103)

* gatio: fix MessageID regression (cherry-pick me)

* Update exchanges/gateio/gateio_wrapper_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* glorious: AI

* Update exchanges/gateio/gateio_wrapper.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* thrasher: use optimisation in okx as well

* okx: Add length check in tests for string -> uuid conversion

* thrasher: nits

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>
This commit is contained in:
Ryan O'Hara-Reid
2025-11-11 14:25:21 +11:00
committed by GitHub
parent 2fd4f5ec5b
commit fefb866b02
6 changed files with 60 additions and 20 deletions

View File

@@ -2,6 +2,7 @@ package gateio
import (
"context"
"encoding/hex"
"errors"
"fmt"
"math"
@@ -11,6 +12,7 @@ import (
"strings"
"time"
"github.com/gofrs/uuid"
"github.com/shopspring/decimal"
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/common/key"
@@ -2645,3 +2647,11 @@ func (e *Exchange) WebsocketSubmitOrders(ctx context.Context, orders []*order.Su
return nil, fmt.Errorf("%w for %s", common.ErrNotYetImplemented, a)
}
}
// MessageID returns a unique ID conforming to Gate's max length of 32 bytes for request IDs
func (e *Exchange) MessageID() string {
u := uuid.Must(uuid.NewV7())
var buf [32]byte
hex.Encode(buf[:], u[:])
return string(buf[:])
}