@dignetwork/dig-sdk 0.0.1-alpha.48 → 0.0.1-alpha.49
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerCoin.d.ts","sourceRoot":"","sources":["../../src/blockchain/ServerCoin.ts"],"names":[],"mappings":"AACA,OAAO,EAML,UAAU,IAAI,gBAAgB,EAE/B,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"ServerCoin.d.ts","sourceRoot":"","sources":["../../src/blockchain/ServerCoin.ts"],"names":[],"mappings":"AACA,OAAO,EAML,UAAU,IAAI,gBAAgB,EAE/B,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAUrD,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,gBAAuB,iBAAiB,eAEtC;gBAEU,OAAO,EAAE,MAAM;IAKd,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA2DzD,kBAAkB,CAC7B,UAAU,EAAE,gBAAgB,EAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC;IAqBH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAoDjD,oBAAoB;IAerB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IA2C5E,mBAAmB,CAC9B,SAAS,GAAE,MAAM,EAAO,GACvB,OAAO,CAAC,MAAM,EAAE,CAAC;IAMP,kBAAkB,CAC7B,UAAU,GAAE,MAAU,EACtB,SAAS,GAAE,MAAM,EAAO,GACvB,OAAO,CAAC,MAAM,EAAE,CAAC;IAMP,wBAAwB,CACnC,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAU,EACtB,SAAS,GAAE,MAAM,EAAO,GACvB,OAAO,CAAC,MAAM,EAAE,CAAC;WASN,eAAe,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAKpD,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiDrD,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WA+B1C,uBAAuB;YAkE7B,sBAAsB;IAWvB,uBAAuB,CAClC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC;WAuBL,sBAAsB,CAAC,mBAAmB,EAAE,IAAI,GAAG;QAC/D,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf;CA2BF"}
|
|
@@ -11,7 +11,10 @@ const coins_1 = require("./coins");
|
|
|
11
11
|
const Wallet_1 = require("./Wallet");
|
|
12
12
|
const NconfManager_1 = require("../utils/NconfManager");
|
|
13
13
|
const DataStore_1 = require("./DataStore");
|
|
14
|
+
const node_cache_1 = __importDefault(require("node-cache"));
|
|
14
15
|
const serverCoinCollateral = 300000000;
|
|
16
|
+
// Initialize the cache with a TTL of 300 seconds (5 minutes)
|
|
17
|
+
const serverCoinPeersCache = new node_cache_1.default({ stdTTL: 300 });
|
|
15
18
|
class ServerCoin {
|
|
16
19
|
constructor(storeId) {
|
|
17
20
|
this.storeId = storeId;
|
|
@@ -95,6 +98,12 @@ class ServerCoin {
|
|
|
95
98
|
await ServerCoin.serverCoinManager.setConfigValue(`${this.storeId}:${peerIp}`, serverCoins);
|
|
96
99
|
}
|
|
97
100
|
async getAllEpochPeers(epoch, blacklist = []) {
|
|
101
|
+
const cacheKey = `serverCoinPeers-${this.storeId}-${epoch}`;
|
|
102
|
+
// Check if the result is already cached
|
|
103
|
+
const cachedPeers = serverCoinPeersCache.get(cacheKey);
|
|
104
|
+
if (cachedPeers) {
|
|
105
|
+
return cachedPeers;
|
|
106
|
+
}
|
|
98
107
|
const epochBasedHint = (0, datalayer_driver_1.morphLauncherId)(Buffer.from(this.storeId, "hex"), BigInt(epoch));
|
|
99
108
|
const peer = await FullNodePeer_1.FullNodePeer.connect();
|
|
100
109
|
const maxClvmCost = BigInt(11000000000);
|
|
@@ -112,7 +121,10 @@ class ServerCoin {
|
|
|
112
121
|
if (process.env.DIG_DEBUG === "1") {
|
|
113
122
|
console.log("Server Coin Peers: ", serverCoinPeers);
|
|
114
123
|
}
|
|
115
|
-
|
|
124
|
+
const peerList = Array.from(serverCoinPeers);
|
|
125
|
+
// Cache the result
|
|
126
|
+
serverCoinPeersCache.set(cacheKey, peerList);
|
|
127
|
+
return peerList;
|
|
116
128
|
}
|
|
117
129
|
async getActiveEpochPeers(blacklist = []) {
|
|
118
130
|
const { epoch } = ServerCoin.getCurrentEpoch();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dignetwork/dig-sdk",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.49",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"merkletreejs": "^0.4.0",
|
|
42
42
|
"nanospinner": "^1.1.0",
|
|
43
43
|
"nconf": "^0.12.1",
|
|
44
|
+
"node-cache": "^5.1.2",
|
|
44
45
|
"p-limit": "^6.1.0",
|
|
45
46
|
"superagent": "^10.0.0"
|
|
46
47
|
},
|