@dignetwork/dig-sdk 0.0.1-alpha.9 → 0.0.1-alpha.90
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.
- package/dist/DataIntegrityTree/DataIntegrityTree.d.ts +5 -2
- package/dist/DataIntegrityTree/DataIntegrityTree.d.ts.map +1 -1
- package/dist/DataIntegrityTree/DataIntegrityTree.js +93 -34
- package/dist/DigNetwork/ContentServer.d.ts +9 -4
- package/dist/DigNetwork/ContentServer.d.ts.map +1 -1
- package/dist/DigNetwork/ContentServer.js +55 -19
- package/dist/DigNetwork/DigNetwork.d.ts +3 -9
- package/dist/DigNetwork/DigNetwork.d.ts.map +1 -1
- package/dist/DigNetwork/DigNetwork.js +98 -189
- package/dist/DigNetwork/DigPeer.d.ts +8 -3
- package/dist/DigNetwork/DigPeer.d.ts.map +1 -1
- package/dist/DigNetwork/DigPeer.js +65 -114
- package/dist/DigNetwork/PropagationServer.d.ts +67 -33
- package/dist/DigNetwork/PropagationServer.d.ts.map +1 -1
- package/dist/DigNetwork/PropagationServer.js +484 -363
- package/dist/blockchain/DataStore.d.ts +18 -7
- package/dist/blockchain/DataStore.d.ts.map +1 -1
- package/dist/blockchain/DataStore.js +78 -98
- package/dist/blockchain/DataStoreSerializer.d.ts +1 -1
- package/dist/blockchain/DataStoreSerializer.d.ts.map +1 -1
- package/dist/blockchain/FullNodePeer.d.ts +9 -1
- package/dist/blockchain/FullNodePeer.d.ts.map +1 -1
- package/dist/blockchain/FullNodePeer.js +36 -10
- package/dist/blockchain/ServerCoin.d.ts +11 -3
- package/dist/blockchain/ServerCoin.d.ts.map +1 -1
- package/dist/blockchain/ServerCoin.js +51 -17
- package/dist/blockchain/Wallet.d.ts +2 -2
- package/dist/blockchain/Wallet.d.ts.map +1 -1
- package/dist/blockchain/Wallet.js +51 -18
- package/dist/blockchain/coins.d.ts +1 -1
- package/dist/blockchain/coins.d.ts.map +1 -1
- package/dist/blockchain/coins.js +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/ContentScanner.d.ts +63 -0
- package/dist/utils/ContentScanner.d.ts.map +1 -0
- package/dist/utils/ContentScanner.js +175 -0
- package/dist/utils/FileTransfer.d.ts +47 -0
- package/dist/utils/FileTransfer.d.ts.map +1 -0
- package/dist/utils/FileTransfer.js +209 -0
- package/dist/utils/StoreArchiveManager.d.ts +45 -0
- package/dist/utils/StoreArchiveManager.d.ts.map +1 -0
- package/dist/utils/StoreArchiveManager.js +153 -0
- package/dist/utils/asyncPool.d.ts +9 -0
- package/dist/utils/asyncPool.d.ts.map +1 -0
- package/dist/utils/asyncPool.js +23 -0
- package/dist/utils/config.d.ts +4 -3
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +9 -5
- package/dist/utils/directoryUtils.d.ts +0 -6
- package/dist/utils/directoryUtils.d.ts.map +1 -1
- package/dist/utils/directoryUtils.js +30 -11
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/merkle.d.ts +2 -0
- package/dist/utils/merkle.d.ts.map +1 -0
- package/dist/utils/merkle.js +28 -0
- package/dist/utils/network.d.ts.map +1 -1
- package/dist/utils/network.js +24 -9
- package/package.json +13 -3
- package/dist/utils/deltaUtils.d.ts +0 -2
- package/dist/utils/deltaUtils.d.ts.map +0 -1
- package/dist/utils/deltaUtils.js +0 -83
package/dist/utils/deltaUtils.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getDeltaFiles = void 0;
|
|
27
|
-
const fs = __importStar(require("fs"));
|
|
28
|
-
const path = __importStar(require("path"));
|
|
29
|
-
const hashUtils_1 = require("./hashUtils");
|
|
30
|
-
const getDeltaFiles = async (storeId, generationIndex = 0, directoryPath) => {
|
|
31
|
-
if (isNaN(generationIndex)) {
|
|
32
|
-
generationIndex = 0;
|
|
33
|
-
}
|
|
34
|
-
// Load manifest file
|
|
35
|
-
const manifestFilePath = path.join(directoryPath, storeId, "manifest.dat");
|
|
36
|
-
if (!fs.existsSync(manifestFilePath)) {
|
|
37
|
-
console.error("Manifest file not found", manifestFilePath);
|
|
38
|
-
return [];
|
|
39
|
-
}
|
|
40
|
-
const manifestHashes = fs
|
|
41
|
-
.readFileSync(manifestFilePath, "utf-8")
|
|
42
|
-
.split("\n")
|
|
43
|
-
.filter(Boolean);
|
|
44
|
-
console.log("");
|
|
45
|
-
console.log(`Uploading delta from generation ${generationIndex}`);
|
|
46
|
-
const filesInvolved = [];
|
|
47
|
-
// Include the height.dat file at the top of the directory
|
|
48
|
-
const heightDatFilePath = path.join(directoryPath, storeId, "height.json");
|
|
49
|
-
if (fs.existsSync(heightDatFilePath)) {
|
|
50
|
-
filesInvolved.push(heightDatFilePath);
|
|
51
|
-
}
|
|
52
|
-
// Collect files starting from generationIndex + 1
|
|
53
|
-
for (let i = generationIndex; i < manifestHashes.length; i++) {
|
|
54
|
-
const rootHash = manifestHashes[i];
|
|
55
|
-
const datFilePath = path.join(directoryPath, storeId, `${rootHash}.dat`);
|
|
56
|
-
if (!fs.existsSync(datFilePath)) {
|
|
57
|
-
console.error(`Data file for root hash ${rootHash} not found`);
|
|
58
|
-
return [];
|
|
59
|
-
}
|
|
60
|
-
const datFileContent = JSON.parse(fs.readFileSync(datFilePath, "utf-8"));
|
|
61
|
-
if (datFileContent.root !== rootHash) {
|
|
62
|
-
console.error(`Root hash in data file does not match: ${datFileContent.root} !== ${rootHash}`);
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
|
-
// Add the .dat file itself to the list of files involved
|
|
66
|
-
filesInvolved.push(datFilePath);
|
|
67
|
-
// Collect all files involved, ensuring correct paths
|
|
68
|
-
for (const file of Object.keys(datFileContent.files)) {
|
|
69
|
-
const filePath = (0, hashUtils_1.getFilePathFromSha256)(datFileContent.files[file].sha256, path.join(directoryPath, storeId, "data"));
|
|
70
|
-
filesInvolved.push(filePath);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (process.env.DIG_DEBUG === "1") {
|
|
74
|
-
console.log("Files involved in the delta:");
|
|
75
|
-
console.table(filesInvolved);
|
|
76
|
-
}
|
|
77
|
-
// list the manifest file last, this actually
|
|
78
|
-
// helps with upload because by overriding the manifest file last,
|
|
79
|
-
// the store can still be considered valid even when the upload is interrupted
|
|
80
|
-
filesInvolved.push(manifestFilePath);
|
|
81
|
-
return filesInvolved;
|
|
82
|
-
};
|
|
83
|
-
exports.getDeltaFiles = getDeltaFiles;
|