tardis-dev 18.0.0 → 18.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +1 -1
  2. package/dist/combine.js +2 -5
  3. package/dist/combine.js.map +1 -1
  4. package/dist/debug.d.ts +12 -2
  5. package/dist/debug.d.ts.map +1 -1
  6. package/dist/debug.js +2 -1
  7. package/dist/debug.js.map +1 -1
  8. package/dist/downloaddatasets.d.ts.map +1 -1
  9. package/dist/downloaddatasets.js +4 -4
  10. package/dist/downloaddatasets.js.map +1 -1
  11. package/dist/foreachconcurrent.d.ts +2 -0
  12. package/dist/foreachconcurrent.d.ts.map +1 -0
  13. package/dist/foreachconcurrent.js +28 -0
  14. package/dist/foreachconcurrent.js.map +1 -0
  15. package/dist/handy.d.ts +3 -1
  16. package/dist/handy.d.ts.map +1 -1
  17. package/dist/handy.js +72 -86
  18. package/dist/handy.js.map +1 -1
  19. package/dist/realtimefeeds/mexc.d.ts +0 -7
  20. package/dist/realtimefeeds/mexc.d.ts.map +1 -1
  21. package/dist/realtimefeeds/mexc.js +2 -70
  22. package/dist/realtimefeeds/mexc.js.map +1 -1
  23. package/dist/realtimefeeds/mexcprotobuf.d.ts +43 -0
  24. package/dist/realtimefeeds/mexcprotobuf.d.ts.map +1 -0
  25. package/dist/realtimefeeds/mexcprotobuf.js +294 -0
  26. package/dist/realtimefeeds/mexcprotobuf.js.map +1 -0
  27. package/dist/realtimefeeds/realtimefeed.d.ts +3 -3
  28. package/dist/realtimefeeds/realtimefeed.d.ts.map +1 -1
  29. package/dist/realtimefeeds/realtimefeed.js +3 -3
  30. package/dist/realtimefeeds/realtimefeed.js.map +1 -1
  31. package/dist/worker.d.ts.map +1 -1
  32. package/dist/worker.js +5 -5
  33. package/dist/worker.js.map +1 -1
  34. package/package.json +3 -8
  35. package/src/combine.ts +2 -4
  36. package/src/debug.ts +16 -1
  37. package/src/downloaddatasets.ts +4 -4
  38. package/src/external-modules.d.ts +5 -0
  39. package/src/foreachconcurrent.ts +29 -0
  40. package/src/handy.ts +93 -89
  41. package/src/realtimefeeds/mexc.ts +2 -72
  42. package/src/realtimefeeds/mexcprotobuf.ts +364 -0
  43. package/src/realtimefeeds/realtimefeed.ts +5 -5
  44. package/src/worker.ts +8 -12
package/dist/worker.js CHANGED
@@ -1,9 +1,9 @@
1
- import dbg from 'debug';
2
1
  import { existsSync } from 'node:fs';
3
- import pMap from 'p-map';
4
2
  import { isMainThread, parentPort, workerData } from 'worker_threads';
3
+ import { createDebug } from "./debug.js";
4
+ import { forEachConcurrent } from "./foreachconcurrent.js";
5
5
  import { addMinutes, download, formatDateToPath, optimizeFilters, sha256, wait, cleanTempFiles } from "./handy.js";
6
- const debug = dbg('tardis-dev');
6
+ const debug = createDebug('tardis-dev');
7
7
  const DEFAULT_DATA_FEED_SLICE_SIZE = 1;
8
8
  if (isMainThread) {
9
9
  debug('current worker is not meant to run in main thread');
@@ -82,10 +82,10 @@ async function getAvailableDataFeedSlices(payload, filters, cacheDir, minutesCou
82
82
  sliceOffsets.push(offset);
83
83
  }
84
84
  // it both begining and end date of the range is accessible fetch all remaning slices concurently with CONCURRENCY_LIMIT
85
- await pMap(sliceOffsets, async (offset) => {
85
+ await forEachConcurrent(sliceOffsets, concurrencyLimit, async (offset) => {
86
86
  const requestedSliceSize = Math.min(replaySliceSize, minutesCountToFetch - 1 - offset);
87
87
  await getDataFeedSlice(payload, offset, filters, cacheDir, requestedSliceSize);
88
- }, { concurrency: concurrencyLimit });
88
+ });
89
89
  }
90
90
  async function getDataFeedSlice({ exchange, fromDate, endpoint, apiKey, dataFeedCompression, userAgent }, offset, filters, cacheDir, requestedSliceSize = DEFAULT_DATA_FEED_SLICE_SIZE, useCache = true) {
91
91
  const sliceTimestamp = addMinutes(fromDate, offset);
@@ -1 +1 @@
1
- {"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAA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GAAG,CAAC,EAAE,CAAC;QACvB,GAAG,IAAI,YAAY,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,CAAA;IAClE,CAAC;IAED,MAAM,cAAc,GAAG,MAAM,QAAQ,CAAC;QACpC,MAAM;QACN,YAAY,EAAE,aAAa;QAC3B,GAAG;QACH,SAAS;QACT,8BAA8B,EAAE,IAAI;QACpC,cAAc,EAAE,mBAAmB,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY;KACvE,CAAC,CAAA;IACF,MAAM,iBAAiB,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAA;IACxE,MAAM,kBAAkB,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,wBAAwB,CAAC,IAAI,4BAA4B,CAAC,CAAA;IAEnH,KAAK,CAAC,iEAAiE,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAA;IACrG,MAAM,OAAO,GAAkB;QAC7B,QAAQ;QACR,SAAS,EAAE,cAAc,CAAC,YAAY;QACtC,SAAS,EAAE,iBAAiB;KAC7B,CAAA;IACD,UAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;IAEhC,OAAO;QACL,SAAS,EAAE,iBAAiB;QAC5B,kBAAkB;KACnB,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "tardis-dev",
3
- "version": "18.0.0",
3
+ "version": "18.0.2",
4
4
  "engines": {
5
- "node": ">=24.5"
5
+ "node": ">=24.19"
6
6
  },
7
7
  "devEngines": {
8
8
  "runtime": {
9
9
  "name": "node",
10
- "version": ">=24.5"
10
+ "version": ">=24.19"
11
11
  },
12
12
  "packageManager": {
13
13
  "name": "npm",
@@ -69,14 +69,9 @@
69
69
  "license": "MPL-2.0",
70
70
  "dependencies": {
71
71
  "debug": "^4.4.3",
72
- "follow-redirects": "^1.16.0",
73
- "p-map": "^7.0.5",
74
- "protobufjs": "^8.7.1",
75
72
  "ws": "^8.21.1"
76
73
  },
77
74
  "devDependencies": {
78
- "@types/debug": "^4.1.13",
79
- "@types/follow-redirects": "^1.14.4",
80
75
  "@types/node": "^26.1.1",
81
76
  "@types/ws": "^8.18.1",
82
77
  "prettier": "3.8.3",
package/src/combine.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { isManagedRealTimeIterator, mergeRealTime } from './realtimeiterator.ts'
1
+ import { closeIterator, isManagedRealTimeIterator, mergeRealTime } from './realtimeiterator.ts'
2
2
 
3
3
  type NextMessageResultWithIndex = {
4
4
  index: number
@@ -129,8 +129,6 @@ async function* combineHistorical(
129
129
  }
130
130
  } while (aliveIteratorsCount > 0)
131
131
  } finally {
132
- for (let iterator of iterators) {
133
- ;(iterator as any).return()
134
- }
132
+ await Promise.all(iterators.map((iterator) => closeIterator('stream' in iterator ? iterator.stream : iterator)))
135
133
  }
136
134
  }
package/src/debug.ts CHANGED
@@ -1,3 +1,18 @@
1
1
  import dbg from 'debug'
2
2
 
3
- export const debug = dbg('tardis-dev')
3
+ // Keep the public declarations independent from @types/debug. Tardis only relies
4
+ // on this callable part of the logger, while preserving the properties available
5
+ // to subclasses through RealTimeFeedBase.debug.
6
+ export interface DebugLogger {
7
+ (formatter: any, ...args: any[]): void
8
+ color: string
9
+ diff: number
10
+ enabled: boolean
11
+ log: (...args: any[]) => any
12
+ namespace: string
13
+ destroy: () => boolean
14
+ extend: (namespace: string, delimiter?: string) => DebugLogger
15
+ }
16
+
17
+ export const createDebug = dbg as (namespace: string) => DebugLogger
18
+ export const debug = createDebug('tardis-dev')
@@ -1,7 +1,7 @@
1
1
  import { existsSync } from 'node:fs'
2
- import pMap from 'p-map'
3
2
  import { debug } from './debug.ts'
4
3
  import { DatasetType } from './exchangedetails.ts'
4
+ import { forEachConcurrent } from './foreachconcurrent.ts'
5
5
  import { addDays, doubleDigit, download, parseAsUTCDate, sequence } from './handy.ts'
6
6
  import { getOptions } from './options.ts'
7
7
  import { Exchange } from './types.ts'
@@ -62,8 +62,9 @@ export async function downloadDatasets(downloadDatasetsOptions: DownloadDatasets
62
62
  )
63
63
 
64
64
  // download the rest concurrently up to the CONCURRENCY_LIMIT
65
- await pMap(
65
+ await forEachConcurrent(
66
66
  sequence(daysCountToFetch - 1, 1), // this will produce Iterable sequence from 1 to daysCountToFetch - 1 (as we already downloaded data for the first and last day)
67
+ CONCURRENCY_LIMIT,
67
68
  (offset) =>
68
69
  downloadDataSet(
69
70
  getDownloadOptions({
@@ -77,8 +78,7 @@ export async function downloadDatasets(downloadDatasetsOptions: DownloadDatasets
77
78
  date: addDays(startDate, offset)
78
79
  }),
79
80
  skipIfExists
80
- ),
81
- { concurrency: CONCURRENCY_LIMIT }
81
+ )
82
82
  )
83
83
  const elapsedSeconds = (new Date().valueOf() - startTimestamp) / 1000
84
84
 
@@ -0,0 +1,5 @@
1
+ // debug ships JavaScript only; src/debug.ts defines the smaller type surface Tardis uses.
2
+ declare module 'debug' {
3
+ const createDebug: unknown
4
+ export default createDebug
5
+ }
@@ -0,0 +1,29 @@
1
+ export async function forEachConcurrent<T>(items: Iterable<T>, concurrency: number, action: (item: T) => Promise<unknown>) {
2
+ const iterator = items[Symbol.iterator]()
3
+ let hasError = false
4
+ let firstError: unknown
5
+
6
+ const runWorker = async () => {
7
+ while (hasError === false) {
8
+ const next = iterator.next()
9
+ if (next.done) {
10
+ return
11
+ }
12
+
13
+ try {
14
+ await action(next.value)
15
+ } catch (error) {
16
+ if (hasError === false) {
17
+ hasError = true
18
+ firstError = error
19
+ }
20
+ return
21
+ }
22
+ }
23
+ }
24
+
25
+ await Promise.all(Array.from({ length: concurrency }, () => runWorker()))
26
+ if (hasError) {
27
+ throw firstError
28
+ }
29
+ }
package/src/handy.ts CHANGED
@@ -1,14 +1,13 @@
1
1
  import crypto, { createHash } from 'crypto'
2
2
  import { createWriteStream, mkdirSync, rmSync } from 'node:fs'
3
3
  import { rename } from 'node:fs/promises'
4
- import { Agent as HttpAgent } from 'node:http'
5
- import { Agent as HttpsAgent, type RequestOptions } from 'node:https'
6
- import followRedirects from 'follow-redirects'
4
+ import { Agent as HttpAgent, request as httpRequest, type IncomingMessage } from 'node:http'
5
+ import { Agent as HttpsAgent, request as httpsRequest, type RequestOptions } from 'node:https'
6
+ import { pipeline } from 'node:stream/promises'
7
7
  import path from 'path'
8
8
  import { debug } from './debug.ts'
9
9
  import { Mapper } from './mappers/index.ts'
10
10
  import { Disconnect, Exchange, Filter, FilterForExchange } from './types.ts'
11
- const { http: followRedirectsHttp, https: followRedirectsHttps } = followRedirects
12
11
 
13
12
  export function parseAsUTCDate(val: string) {
14
13
  // Treat date-only and minute-level strings as UTC instead of local time.
@@ -456,44 +455,75 @@ async function requestViaFetch(method: string, url: string, options: HttpRequest
456
455
  }
457
456
  }
458
457
 
459
- async function requestViaProxy(method: string, url: string, options: HttpRequestOptions): Promise<HttpResponse> {
460
- const requestClient = new URL(url).protocol === 'http:' ? followRedirectsHttp : followRedirectsHttps
461
- const preparedRequest = prepareRequest(method, options)
458
+ type DownloadRequestOptions = {
459
+ headers: Record<string, string>
460
+ timeout: number
461
+ }
462
462
 
463
- return await new Promise<HttpResponse>((resolve, reject) => {
464
- const request = requestClient
465
- .request(
466
- url,
467
- {
468
- method,
469
- agent: getProxyAgent(url),
470
- headers: preparedRequest.headers,
471
- timeout: options.timeout
472
- },
473
- (response) => {
474
- response.setEncoding('utf8')
475
- let body = ''
476
- response.on('error', reject)
477
- response.on('data', (chunk) => (body += chunk))
478
- response.on('end', () => {
479
- resolve(createHttpResponse(response.statusCode ?? 0, parseNodeResponseHeaders(response.headers), body))
480
- })
481
- }
482
- )
483
- .on('error', reject)
484
- .on('timeout', () => {
485
- reject(new Error('Request timed out'))
486
- request.destroy()
487
- })
488
-
489
- if (preparedRequest.body !== undefined) {
490
- request.write(preparedRequest.body)
491
- }
463
+ function sendHttpRequest(url: string | URL, options: RequestOptions, body?: string): Promise<IncomingMessage> {
464
+ const requestUrl = new URL(url)
465
+ const requestClient = requestUrl.protocol === 'http:' ? httpRequest : httpsRequest
466
+ const agent = getProxyAgent(requestUrl) ?? (requestUrl.protocol === 'https:' ? httpsAgent : undefined)
467
+
468
+ return new Promise((resolve, reject) => {
469
+ const request = requestClient(requestUrl, { ...options, agent }, resolve)
492
470
 
471
+ request.once('error', reject)
472
+ request.once('timeout', () => request.destroy(new Error('Request timed out')))
473
+ if (body !== undefined) {
474
+ request.write(body)
475
+ }
493
476
  request.end()
494
477
  })
495
478
  }
496
479
 
480
+ async function openDownloadResponse(url: string, options: DownloadRequestOptions) {
481
+ const response = await sendHttpRequest(url, options)
482
+ const statusCode = response.statusCode ?? 0
483
+ const location = response.headers.location
484
+ if (location === undefined || statusCode < 300 || statusCode >= 400) {
485
+ return response
486
+ }
487
+
488
+ response.destroy()
489
+ const sourceUrl = new URL(url)
490
+ const redirectUrl = new URL(location, sourceUrl)
491
+ const headers: Record<string, string> = { ...options.headers }
492
+ if (sourceUrl.origin !== redirectUrl.origin) {
493
+ delete headers.Authorization
494
+ delete headers.authorization
495
+ }
496
+
497
+ return sendHttpRequest(redirectUrl, {
498
+ ...options,
499
+ headers
500
+ })
501
+ }
502
+
503
+ async function readResponseText(response: IncomingMessage) {
504
+ response.setEncoding('utf8')
505
+ let body = ''
506
+ for await (const chunk of response) {
507
+ body += chunk
508
+ }
509
+ return body
510
+ }
511
+
512
+ async function requestViaProxy(method: string, url: string, options: HttpRequestOptions): Promise<HttpResponse> {
513
+ const preparedRequest = prepareRequest(method, options)
514
+ const response = await sendHttpRequest(
515
+ url,
516
+ {
517
+ method,
518
+ headers: preparedRequest.headers,
519
+ timeout: options.timeout
520
+ },
521
+ preparedRequest.body
522
+ )
523
+
524
+ return createHttpResponse(response.statusCode ?? 0, parseNodeResponseHeaders(response.headers), await readResponseText(response))
525
+ }
526
+
497
527
  async function request(method: string, url: string, options: HttpRequestOptions = {}) {
498
528
  const retrySettings = getRetrySettings(method, options.retry)
499
529
 
@@ -622,7 +652,12 @@ export function cleanTempFiles() {
622
652
  tmpFileCleanups.forEach((cleanup) => cleanup())
623
653
  }
624
654
 
625
- async function _downloadFile(requestOptions: RequestOptions, url: string, downloadPath: string, appendContentEncodingExtension: boolean) {
655
+ async function _downloadFile(
656
+ requestOptions: DownloadRequestOptions,
657
+ url: string,
658
+ downloadPath: string,
659
+ appendContentEncodingExtension: boolean
660
+ ) {
626
661
  // first ensure that directory where we want to download file exists
627
662
  mkdirSync(path.dirname(downloadPath), { recursive: true })
628
663
 
@@ -642,59 +677,28 @@ async function _downloadFile(requestOptions: RequestOptions, url: string, downlo
642
677
 
643
678
  try {
644
679
  // based on https://github.com/nodejs/node/issues/28172 - only reliable way to consume response stream and avoiding all the 'gotchas'
645
- let responseHeaders: Record<string, string> = {}
646
- await new Promise<void>((resolve, reject) => {
647
- const protocol = new URL(url).protocol
648
- const requestClient = protocol === 'http:' ? followRedirectsHttp : followRedirectsHttps
649
- const agent = getProxyAgent(url) ?? (protocol === 'https:' ? httpsAgent : undefined)
650
- const req = requestClient
651
- .get(url, { ...requestOptions, agent }, (res) => {
652
- const { statusCode } = res
653
- if (statusCode !== 200) {
654
- // read the error response text and throw it as an HttpError
655
- res.setEncoding('utf8')
656
- let body = ''
657
- res.on('error', reject)
658
- res.on('data', (chunk) => (body += chunk))
659
- res.on('end', () => {
660
- reject(new HttpError(statusCode!, body, url))
661
- })
662
- } else {
663
- responseHeaders = parseNodeResponseHeaders(res.headers)
664
- if (appendContentEncodingExtension) {
665
- const contentEncoding = asSingleHeaderValue(res.headers['content-encoding'])
666
- if (contentEncoding === 'zstd') {
667
- finalDownloadPath = `${downloadPath}.zst`
668
- } else if (contentEncoding === undefined || contentEncoding === 'gzip') {
669
- finalDownloadPath = `${downloadPath}.gz`
670
- } else {
671
- reject(new Error(`Unsupported data feed content encoding: ${contentEncoding}`))
672
- return
673
- }
674
- }
680
+ const response = await openDownloadResponse(url, requestOptions)
681
+ const { statusCode } = response
682
+ if (statusCode !== 200) {
683
+ throw new HttpError(statusCode ?? 0, await readResponseText(response), url)
684
+ }
675
685
 
676
- // consume the response stream by writing it to the file
677
- res
678
- .on('error', reject)
679
- .on('aborted', () => reject(new Error('Request aborted')))
680
- .pipe(fileWriteStream)
681
- .on('error', reject)
682
- .on('finish', () => {
683
- if (res.complete) {
684
- resolve()
685
- } else {
686
- reject(new Error('The connection was terminated while the message was still being sent'))
687
- }
688
- })
689
- }
690
- })
691
- .on('error', reject)
692
- .on('timeout', () => {
693
- debug('download file request timeout, %s', url)
694
- reject(new Error('Request timed out'))
695
- req.destroy()
696
- })
697
- })
686
+ const responseHeaders = parseNodeResponseHeaders(response.headers)
687
+ if (appendContentEncodingExtension) {
688
+ const contentEncoding = asSingleHeaderValue(response.headers['content-encoding'])
689
+ if (contentEncoding === 'zstd') {
690
+ finalDownloadPath = `${downloadPath}.zst`
691
+ } else if (contentEncoding === undefined || contentEncoding === 'gzip') {
692
+ finalDownloadPath = `${downloadPath}.gz`
693
+ } else {
694
+ throw new Error(`Unsupported data feed content encoding: ${contentEncoding}`)
695
+ }
696
+ }
697
+
698
+ await pipeline(response, fileWriteStream)
699
+ if (!response.complete) {
700
+ throw new Error('The connection was terminated while the message was still being sent')
701
+ }
698
702
 
699
703
  // finally when saving from the network to file has succeded, rename tmp file to normal name
700
704
  // then we're sure that responses is 100% saved and also even if different process was doing the same we're good
@@ -1,71 +1,13 @@
1
- import protobuf from 'protobufjs'
2
1
  import { CircularBuffer, getJSON, wait } from '../handy.ts'
3
2
  import type { MexcDepthSnapshotMessage } from '../mappers/mexc.ts'
4
3
  import { Filter } from '../types.ts'
5
4
  import { RealTimeFeedBase } from './realtimefeed.ts'
5
+ import { decodeMexcProtobufMessage } from './mexcprotobuf.ts'
6
6
 
7
7
  export class MexcRealTimeFeed extends RealTimeFeedBase {
8
8
  private static readonly depthChannel = 'spot@public.aggre.depth.v3.api.pb@10ms'
9
9
  private static readonly depthSnapshotChannel = 'spot@public.aggre.depth.snapshot.v3.api.pb@10ms'
10
10
  private static readonly jsonObjectStart = '{'.charCodeAt(0)
11
- private static pushDataV3ApiWrapper: protobuf.Type | undefined
12
- /**
13
- * MEXC protobuf docs at @see https://www.mexc.com/api-docs/spot-v3/websocket-market-streams/protocol-buffers-integration
14
- * and schemas from @see https://github.com/mexcdevelop/websocket-proto, mirrored in tardis-recorder/datafeeds/src/mexc/proto.
15
- */
16
- private static readonly pushDataV3ApiWrapperSchema = `
17
- syntax = "proto3";
18
-
19
- message PushDataV3ApiWrapper {
20
- string channel = 1;
21
- oneof body {
22
- PublicAggreDepthsV3Api publicAggreDepths = 313;
23
- PublicAggreDealsV3Api publicAggreDeals = 314;
24
- PublicAggreBookTickerV3Api publicAggreBookTicker = 315;
25
- }
26
-
27
- optional string symbol = 3;
28
- optional string symbolId = 4;
29
- optional int64 createTime = 5;
30
- optional int64 sendTime = 6;
31
- }
32
-
33
- message PublicAggreDealsV3Api {
34
- repeated PublicAggreDealsV3ApiItem deals = 1;
35
- string eventType = 2;
36
- }
37
-
38
- message PublicAggreDealsV3ApiItem {
39
- string price = 1;
40
- string quantity = 2;
41
- int32 tradeType = 3;
42
- int64 time = 4;
43
- string tradeId = 5;
44
- }
45
-
46
- message PublicAggreDepthsV3Api {
47
- repeated PublicAggreDepthV3ApiItem asks = 1;
48
- repeated PublicAggreDepthV3ApiItem bids = 2;
49
- string eventType = 3;
50
- string fromVersion = 4;
51
- string toVersion = 5;
52
- int64 lastOrderCreateTime = 6;
53
- }
54
-
55
- message PublicAggreDepthV3ApiItem {
56
- string price = 1;
57
- string quantity = 2;
58
- }
59
-
60
- message PublicAggreBookTickerV3Api {
61
- string bidPrice = 1;
62
- string bidQuantity = 2;
63
- string askPrice = 3;
64
- string askQuantity = 4;
65
- string version = 5;
66
- int64 lastOrderCreateTime = 6;
67
- }
68
- `
69
11
 
70
12
  private readonly pendingDepthSnapshotSymbols = new Set<string>()
71
13
  private readonly bufferedDepthUpdates = new Map<string, CircularBuffer<MexcDepthUpdateData>>()
@@ -114,11 +56,7 @@ export class MexcRealTimeFeed extends RealTimeFeedBase {
114
56
  return JSON.parse(buffer.toString())
115
57
  }
116
58
 
117
- const pushDataV3ApiWrapper = this.getPushDataV3ApiWrapper()
118
- return pushDataV3ApiWrapper.toObject(pushDataV3ApiWrapper.decode(buffer), {
119
- longs: String,
120
- arrays: true
121
- })
59
+ return decodeMexcProtobufMessage(buffer)
122
60
  }
123
61
 
124
62
  protected override messageIsError(message: any): boolean {
@@ -168,14 +106,6 @@ export class MexcRealTimeFeed extends RealTimeFeedBase {
168
106
  this.send({ method: 'PING' })
169
107
  }
170
108
 
171
- private getPushDataV3ApiWrapper() {
172
- MexcRealTimeFeed.pushDataV3ApiWrapper ??= protobuf
173
- .parse(MexcRealTimeFeed.pushDataV3ApiWrapperSchema)
174
- .root.lookupType('PushDataV3ApiWrapper')
175
-
176
- return MexcRealTimeFeed.pushDataV3ApiWrapper
177
- }
178
-
179
109
  private resetDepthSnapshotTracking(filters: Required<Filter<string>>[]) {
180
110
  this.pendingDepthSnapshotSymbols.clear()
181
111
  this.bufferedDepthUpdates.clear()