@clonegod/ttd-core 3.1.20 → 3.1.22

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.
@@ -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.20",
3
+ "version": "3.1.22",
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",