@dignetwork/dig-sdk 0.0.1-alpha.5 → 0.0.1-alpha.6
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":"DigNetwork.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/DigNetwork.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,qBAAa,UAAU;IACrB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,aAAa,CAA2B;gBAEpC,OAAO,EAAE,MAAM;YAOb,eAAe;IA8ChB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAsDhD,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"DigNetwork.d.ts","sourceRoot":"","sources":["../../src/DigNetwork/DigNetwork.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,qBAAa,UAAU;IACrB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,aAAa,CAA2B;gBAEpC,OAAO,EAAE,MAAM;YAOb,eAAe;IA8ChB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAsDhD,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;WA6BrC,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAQtD,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAQ5C,aAAa,CACxB,aAAa,GAAE,OAAe,EAC9B,iBAAiB,GAAE,OAAc,EACjC,QAAQ,GAAE,OAAe,GACxB,OAAO,CAAC,IAAI,CAAC;YAqFF,mBAAmB;YAWnB,kBAAkB;YASlB,oBAAoB;YASpB,qBAAqB;YAuErB,cAAc;CAoB7B"}
|
|
@@ -101,7 +101,6 @@ class DigNetwork {
|
|
|
101
101
|
async uploadStore(digPeer) {
|
|
102
102
|
const { generationIndex } = await this.uploadPreflight(digPeer);
|
|
103
103
|
const filesToUpload = await (0, deltaUtils_1.getDeltaFiles)(this.dataStore.StoreId, generationIndex, path.resolve(config_1.DIG_FOLDER_PATH, "stores"));
|
|
104
|
-
console.log(filesToUpload);
|
|
105
104
|
if (!filesToUpload.length) {
|
|
106
105
|
console.log("No files to upload.");
|
|
107
106
|
return;
|
|
@@ -246,8 +245,6 @@ class DigNetwork {
|
|
|
246
245
|
}
|
|
247
246
|
async runProgressBar(total, name, task) {
|
|
248
247
|
// Using 'any' to work around TypeScript issues
|
|
249
|
-
const oldConsoleLog = console.log;
|
|
250
|
-
console.log = () => { }; // Suppress console.log output
|
|
251
248
|
const multiBar = new cli_progress_1.MultiBar({
|
|
252
249
|
clearOnComplete: false,
|
|
253
250
|
hideCursor: true,
|
|
@@ -257,7 +254,6 @@ class DigNetwork {
|
|
|
257
254
|
const progress = multiBar.create(total, 0, { name });
|
|
258
255
|
await task(progress).finally(() => {
|
|
259
256
|
multiBar.stop();
|
|
260
|
-
console.log = oldConsoleLog; // Restore console.log
|
|
261
257
|
});
|
|
262
258
|
}
|
|
263
259
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FullNodePeer.d.ts","sourceRoot":"","sources":["../../src/blockchain/FullNodePeer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAmBxC,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,UAAU,CAAkD;IAC3E,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAA0B;IAChE,OAAO,CAAC,IAAI,CAAO;IAQnB,OAAO;WAIa,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5C,OAAO,CAAC,MAAM,CAAC,eAAe;IAiB9B,OAAO,CAAC,MAAM,CAAC,gBAAgB;mBAOV,eAAe;mBAkDf,UAAU;IAyB/B,OAAO,CAAC,MAAM,CAAC,eAAe;
|
|
1
|
+
{"version":3,"file":"FullNodePeer.d.ts","sourceRoot":"","sources":["../../src/blockchain/FullNodePeer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAmBxC,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,UAAU,CAAkD;IAC3E,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAA0B;IAChE,OAAO,CAAC,IAAI,CAAO;IAQnB,OAAO;WAIa,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5C,OAAO,CAAC,MAAM,CAAC,eAAe;IAiB9B,OAAO,CAAC,MAAM,CAAC,gBAAgB;mBAOV,eAAe;mBAkDf,UAAU;IAyB/B,OAAO,CAAC,MAAM,CAAC,eAAe;mBA8CT,WAAW;IAgGzB,OAAO,IAAI,IAAI;WAIF,mBAAmB,CACrC,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,CAAC;CAwBpB"}
|
|
@@ -107,17 +107,35 @@ class FullNodePeer {
|
|
|
107
107
|
}
|
|
108
108
|
return FullNodePeer.memoizedFetchNewPeerIPs();
|
|
109
109
|
}
|
|
110
|
-
static createPeerProxy(peer
|
|
110
|
+
static createPeerProxy(peer) {
|
|
111
111
|
return new Proxy(peer, {
|
|
112
112
|
get: (target, prop) => {
|
|
113
113
|
const originalMethod = target[prop];
|
|
114
114
|
if (typeof originalMethod === "function") {
|
|
115
115
|
return async (...args) => {
|
|
116
|
+
let timeoutId;
|
|
117
|
+
// Start the timeout to forget the peer after 1 minute
|
|
118
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
119
|
+
timeoutId = setTimeout(() => {
|
|
120
|
+
FullNodePeer.cachedPeer = null;
|
|
121
|
+
reject(new Error("Operation timed out. Reconnecting to a new peer."));
|
|
122
|
+
}, 60000); // 1 minute
|
|
123
|
+
});
|
|
116
124
|
try {
|
|
117
|
-
|
|
125
|
+
// Run the original method and race it against the timeout
|
|
126
|
+
const result = await Promise.race([
|
|
127
|
+
originalMethod.apply(target, args),
|
|
128
|
+
timeoutPromise,
|
|
129
|
+
]);
|
|
130
|
+
// Clear the timeout if the operation succeeded
|
|
131
|
+
if (timeoutId) {
|
|
132
|
+
clearTimeout(timeoutId);
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
118
135
|
}
|
|
119
136
|
catch (error) {
|
|
120
|
-
|
|
137
|
+
// If the error is WebSocket-related or timeout, reset the peer
|
|
138
|
+
if (error.message.includes("WebSocket") || error.message.includes("Operation timed out")) {
|
|
121
139
|
FullNodePeer.cachedPeer = null;
|
|
122
140
|
const newPeer = await FullNodePeer.getBestPeer();
|
|
123
141
|
return newPeer[prop](...args);
|
|
@@ -149,7 +167,7 @@ class FullNodePeer {
|
|
|
149
167
|
if (ip) {
|
|
150
168
|
try {
|
|
151
169
|
const peer = await datalayer_driver_1.Peer.new(`${ip}:${FULLNODE_PORT}`, false, certFile, keyFile);
|
|
152
|
-
return FullNodePeer.createPeerProxy(peer
|
|
170
|
+
return FullNodePeer.createPeerProxy(peer);
|
|
153
171
|
}
|
|
154
172
|
catch (error) {
|
|
155
173
|
console.error(`Failed to create peer for IP ${ip}: ${error.message}`);
|