add LastUpdateId to the SliceOrderBook struct

This commit is contained in:
c9s 2024-02-06 12:27:07 +08:00
parent b3ef66dff4
commit f734c699bc
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 6 additions and 0 deletions

View File

@ -1357,6 +1357,7 @@ func (e *Exchange) QueryDepth(ctx context.Context, symbol string) (snapshot type
func convertDepth(symbol string, response *binanceapi.Depth) (snapshot types.SliceOrderBook, finalUpdateID int64, err error) { func convertDepth(symbol string, response *binanceapi.Depth) (snapshot types.SliceOrderBook, finalUpdateID int64, err error) {
snapshot.Symbol = symbol snapshot.Symbol = symbol
snapshot.Time = time.Now() snapshot.Time = time.Now()
snapshot.LastUpdateId = response.LastUpdateId
finalUpdateID = response.LastUpdateId finalUpdateID = response.LastUpdateId
for _, entry := range response.Bids { for _, entry := range response.Bids {

View File

@ -21,6 +21,11 @@ type SliceOrderBook struct {
// Time represents the server time. If empty, it indicates that the server does not provide this information. // Time represents the server time. If empty, it indicates that the server does not provide this information.
Time time.Time Time time.Time
// LastUpdateId is the message id from the server
// this field is optional, not every exchange provides this information
// this is for binance right now.
LastUpdateId int64
lastUpdateTime time.Time lastUpdateTime time.Time
loadCallbacks []func(book *SliceOrderBook) loadCallbacks []func(book *SliceOrderBook)