@dignetwork/dig-sdk 0.0.1-alpha.131 → 0.0.1-alpha.133
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.
|
@@ -4,6 +4,7 @@ export declare class DigNetwork {
|
|
|
4
4
|
private serverCoin;
|
|
5
5
|
private storeDir;
|
|
6
6
|
private peerBlacklist;
|
|
7
|
+
private static networkSyncMap;
|
|
7
8
|
constructor(storeId: string);
|
|
8
9
|
static subscribeToStore(storeId: string): Promise<void>;
|
|
9
10
|
static getUdiContent(udi: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DigNetwork.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/DigNetwork.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"DigNetwork.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/DigNetwork.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,qBAAa,UAAU;IACrB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,MAAM,CAAC,cAAc,CAAmC;gBAEpD,OAAO,EAAE,MAAM;WAOP,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAQhD,aAAa,CAAC,GAAG,EAAE,MAAM;WAIzB,oBAAoB,CACtC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,MAAM,EACZ,gBAAgB,GAAE,MAAM,EAAO,GAC9B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;WA0EZ,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;WAOrC,mBAAmB,CACrC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IAcH,kBAAkB,CAC7B,eAAe,CAAC,EAAE,OAAO,EACzB,iBAAiB,CAAC,EAAE,MAAM,GACzB,OAAO,CAAC,IAAI,CAAC;IA8GH,mBAAmB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAUvD"}
|
|
@@ -30,9 +30,6 @@ const DigPeer_1 = require("./DigPeer");
|
|
|
30
30
|
const blockchain_1 = require("../blockchain");
|
|
31
31
|
const config_1 = require("../utils/config");
|
|
32
32
|
const utils_1 = require("../utils");
|
|
33
|
-
const util_1 = require("util");
|
|
34
|
-
const rename = (0, util_1.promisify)(fs.rename);
|
|
35
|
-
const unlink = (0, util_1.promisify)(fs.unlink);
|
|
36
33
|
class DigNetwork {
|
|
37
34
|
constructor(storeId) {
|
|
38
35
|
this.dataStore = blockchain_1.DataStore.from(storeId);
|
|
@@ -123,7 +120,12 @@ class DigNetwork {
|
|
|
123
120
|
}
|
|
124
121
|
}
|
|
125
122
|
async syncStoreFromPeers(prioritizedPeer, maxRootsToProcess) {
|
|
126
|
-
|
|
123
|
+
// Check if synchronization is already active for this storeId
|
|
124
|
+
if (DigNetwork.networkSyncMap.get(this.dataStore.StoreId)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
console.log("Starting network sync for store:", this.dataStore.StoreId);
|
|
128
|
+
DigNetwork.networkSyncMap.set(this.dataStore.StoreId, true);
|
|
127
129
|
let peerBlackList = [];
|
|
128
130
|
try {
|
|
129
131
|
const rootHistory = await this.dataStore.getRootHistory();
|
|
@@ -181,7 +183,6 @@ class DigNetwork {
|
|
|
181
183
|
}
|
|
182
184
|
}
|
|
183
185
|
}
|
|
184
|
-
DigNetwork.pingNetworkOfUpdate(this.dataStore.StoreId, rootInfo.root_hash);
|
|
185
186
|
}
|
|
186
187
|
console.log("Syncing store complete.");
|
|
187
188
|
}
|
|
@@ -189,6 +190,11 @@ class DigNetwork {
|
|
|
189
190
|
console.error("Error during syncing store from peers:", error);
|
|
190
191
|
throw error;
|
|
191
192
|
}
|
|
193
|
+
finally {
|
|
194
|
+
// Mark synchronization as inactive for this storeId
|
|
195
|
+
DigNetwork.networkSyncMap.set(this.dataStore.StoreId, false);
|
|
196
|
+
console.log(`Network sync for storeId: ${this.dataStore.StoreId} has completed.`);
|
|
197
|
+
}
|
|
192
198
|
}
|
|
193
199
|
// Fetches available peers for the store
|
|
194
200
|
async fetchAvailablePeers() {
|
|
@@ -199,3 +205,4 @@ class DigNetwork {
|
|
|
199
205
|
}
|
|
200
206
|
}
|
|
201
207
|
exports.DigNetwork = DigNetwork;
|
|
208
|
+
DigNetwork.networkSyncMap = new Map();
|