@clonegod/ttd-core 3.1.21 → 3.1.23

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.
@@ -5,7 +5,6 @@ const __1 = require("..");
5
5
  const env_loader_1 = require("./env_loader");
6
6
  class EnvArgs {
7
7
  constructor(chain_id, dex_id) {
8
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
9
8
  const overrides = {};
10
9
  if (chain_id)
11
10
  overrides.chain_id = chain_id;
@@ -13,54 +12,10 @@ class EnvArgs {
13
12
  overrides.dex_id = dex_id;
14
13
  const cfg = (0, env_loader_1.loadEnvConfig)(overrides);
15
14
  this._cfg = cfg;
16
- this.app_name = cfg.app_name || '';
17
- this.app_base_dir = cfg.app_base_dir || '';
18
- this.chain_id = (cfg.chain_id || '').toUpperCase();
19
- this.dex_id = (cfg.dex_id || '').toUpperCase();
20
- if ((0, __1.isEmpty)(this.chain_id)) {
15
+ const cid = (cfg.chain_id || '').toUpperCase();
16
+ if ((0, __1.isEmpty)(cid)) {
21
17
  throw new Error(`environment: CHAIN_ID is empty!!!`);
22
18
  }
23
- this.log_level = (_a = cfg.log_level) !== null && _a !== void 0 ? _a : '';
24
- this.log_depth = cfg.log_depth;
25
- this.server_id = (_b = cfg.server_id) !== null && _b !== void 0 ? _b : '';
26
- this.redis_host = cfg.redis_host;
27
- this.redis_port = String(cfg.redis_port);
28
- this.config_center_host = cfg.config_center_host;
29
- this.enable_init_cache = (_c = cfg.enable_init_cache) !== null && _c !== void 0 ? _c : '';
30
- this.trade_analyze_url = cfg.trade_analyze_url;
31
- this.trade_analyze_host = (_d = cfg.trade_analyze_host) !== null && _d !== void 0 ? _d : '';
32
- this.rpc_endpoint = cfg.rpc_endpoint;
33
- this.ws_endpoint = cfg.ws_endpoint;
34
- this.grpc_endpoint = cfg.grpc_endpoint;
35
- this.grpc_token = cfg.grpc_token;
36
- this.auto_quote_enable = cfg.auto_quote_enable;
37
- this.auto_quote_interval_mills = cfg.auto_quote_interval_mills;
38
- this.quote_pair = cfg.quote_pair;
39
- this.quote_amount_usd = cfg.quote_amount_usd;
40
- this.quote_pool_address = cfg.quote_pool_address;
41
- this.quote_pool_name = cfg.quote_pool_name;
42
- this.quote_pool_fee_rate = cfg.quote_pool_fee_rate;
43
- this.tick_cache_force_full_refresh_interval = cfg.tick_cache_force_full_refresh_interval;
44
- this.depth_cex_bps = cfg.depth_cex_bps;
45
- this.group_id = (_e = cfg.group_id) !== null && _e !== void 0 ? _e : '';
46
- this.trade_group_id = cfg.trade_group_id;
47
- this.trade_pair = cfg.trade_pair;
48
- this.trade_log_report_cex_url = (_f = cfg.trade_log_report_cex_url) !== null && _f !== void 0 ? _f : '';
49
- this.trade_log_report_cex_data_type = (_g = cfg.trade_log_report_cex_data_type) !== null && _g !== void 0 ? _g : '';
50
- this.token_price_cache_seconds = cfg.token_price_cache_seconds;
51
- this.token_market_price_url = (_h = cfg.token_market_price_url) !== null && _h !== void 0 ? _h : '';
52
- this.wallet_dir = cfg.wallet_dir;
53
- this.encryption_key = (_j = cfg.encryption_key) !== null && _j !== void 0 ? _j : '';
54
- this.providers_file_path = cfg.providers_file_path;
55
- this.fixed_symbol_address_file = (_k = cfg.fixed_symbol_address_file) !== null && _k !== void 0 ? _k : '';
56
- this.zh_pinyin_map_file = (_l = cfg.zh_pinyin_map_file) !== null && _l !== void 0 ? _l : '';
57
- this.alert_analyze_host = (_m = cfg.alert_analyze_host) !== null && _m !== void 0 ? _m : '';
58
- this.alert_flush_size = cfg.alert_flush_size;
59
- this.alert_flush_ms = cfg.alert_flush_ms;
60
- this.alert_dedup_window_ms = cfg.alert_dedup_window_ms;
61
- this.namespace = (_o = cfg.namespace) !== null && _o !== void 0 ? _o : '';
62
- this.server_ip_list = (_p = cfg.server_ip_list) !== null && _p !== void 0 ? _p : '';
63
- this.ip_exclude_prefix = (_q = cfg.ip_exclude_prefix) !== null && _q !== void 0 ? _q : '';
64
19
  }
65
20
  print(moduleName) {
66
21
  (0, env_loader_1.printEnvConfig)(moduleName || this.app_name || 'EnvArgs', this);
@@ -39,8 +39,15 @@ exports.getCurrentIpList = getCurrentIpList;
39
39
  require('dotenv').config();
40
40
  const os = __importStar(require("os"));
41
41
  const core_env_1 = require("../app_config/core_env");
42
- let IP_LIST = getServerIpList();
42
+ let IP_LIST = [];
43
+ let ip_list_loaded = false;
43
44
  let ip_counter = 0;
45
+ function ensureIpListLoaded() {
46
+ if (!ip_list_loaded) {
47
+ IP_LIST = getServerIpList();
48
+ ip_list_loaded = true;
49
+ }
50
+ }
44
51
  function getProxyIpFromEnv() {
45
52
  const coreEnv = (0, core_env_1.getCoreEnv)();
46
53
  const raw = coreEnv.server_ip_list || '';
@@ -83,12 +90,9 @@ function getServerIpList() {
83
90
  }
84
91
  function getNextIP() {
85
92
  try {
86
- if (IP_LIST.length === 0) {
87
- IP_LIST = getServerIpList();
88
- }
89
- if (IP_LIST.length === 0) {
93
+ ensureIpListLoaded();
94
+ if (IP_LIST.length === 0)
90
95
  return undefined;
91
- }
92
96
  return IP_LIST[ip_counter++ % IP_LIST.length];
93
97
  }
94
98
  catch (err) {
@@ -97,5 +101,6 @@ function getNextIP() {
97
101
  }
98
102
  }
99
103
  function getCurrentIpList() {
104
+ ensureIpListLoaded();
100
105
  return [...IP_LIST];
101
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clonegod/ttd-core",
3
- "version": "3.1.21",
3
+ "version": "3.1.23",
4
4
  "description": "Common types and utilities for trading systems - use `npm run push` to publish",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",