Skip to content

Commit b2bbbd5

Browse files
Merge pull request #39 from DIG-Network/release/v0.0.1-alpha.40
Release/v0.0.1 alpha.40
2 parents fd29e4c + fc93e0b commit b2bbbd5

File tree

4 files changed

+50
-30
lines changed

4 files changed

+50
-30
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
### [0.0.1-alpha.40](https://github.com/DIG-Network/dig-cli/compare/v0.0.1-alpha.39...v0.0.1-alpha.40) (2024-10-10)
6+
57
### [0.0.1-alpha.39](https://github.com/DIG-Network/dig-cli/compare/v0.0.1-alpha.38...v0.0.1-alpha.39) (2024-10-08)
68

79
### [0.0.1-alpha.38](https://github.com/DIG-Network/dig-cli/compare/v0.0.1-alpha.37...v0.0.1-alpha.38) (2024-10-03)

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dignetwork/dig-chia-cli",
3-
"version": "0.0.1-alpha.39",
3+
"version": "0.0.1-alpha.40",
44
"description": "",
55
"type": "commonjs",
66
"main": "./dist/cli.js",
@@ -24,7 +24,7 @@
2424
"LICENSE"
2525
],
2626
"dependencies": {
27-
"@dignetwork/dig-sdk": "^0.0.1-alpha.167",
27+
"@dignetwork/dig-sdk": "^0.0.1-alpha.169",
2828
"bip39": "^3.1.0",
2929
"datalayer-driver": "^0.1.21",
3030
"inquirer": "^10.1.8",

src/actions/commit.ts

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import path from "path";
22
import fs from "fs";
33
import {
4-
addDirectory,
4+
listFilesRecursively,
5+
asyncPool,
56
calculateFolderSize,
67
waitForPromise,
78
DataStore,
@@ -29,34 +30,51 @@ export const commit = async (): Promise<void> => {
2930

3031
const digConfig = await loadDigConfig(process.cwd());
3132

32-
await addDirectory(
33-
dataStore.Tree,
34-
path.join(process.cwd(), digConfig.deploy_dir)
33+
// Group into 1000 files per batch to make management and upload easier
34+
const fileGroups = listFilesRecursively(
35+
path.join(process.cwd(), digConfig.deploy_dir),
36+
1000
3537
);
3638

37-
const newRootHash = dataStore.Tree.commit();
39+
const concurrencyLimit = 10;
3840

39-
if (!newRootHash) {
40-
return;
41-
}
41+
for (const files of fileGroups) {
42+
await asyncPool(concurrencyLimit, files as string[], async (file) => {
43+
const filePath = path.join(process.cwd(), digConfig.deploy_dir, file);
44+
const relativePath = file.replace(/\\/g, "/");
45+
const stream = fs.createReadStream(filePath);
46+
await dataStore.Tree.upsertKey(
47+
stream,
48+
Buffer.from(relativePath).toString("hex")
49+
);
50+
});
4251

43-
const totalBytes = calculateFolderSize(
44-
path.resolve(STORE_PATH, dataStore.StoreId)
45-
);
52+
const newRootHash = dataStore.Tree.commit();
4653

47-
console.log(
48-
`Updating store metadata with new root hash: ${newRootHash}, bytes: ${totalBytes}`
49-
);
54+
if (!newRootHash) {
55+
return;
56+
}
5057

51-
const updatedStoreInfo = await dataStore.updateMetadata({
52-
...latestStore.metadata,
53-
rootHash: Buffer.from(newRootHash, "hex"),
54-
bytes: totalBytes,
55-
});
58+
const totalBytes = calculateFolderSize(
59+
path.resolve(STORE_PATH, dataStore.StoreId)
60+
);
5661

57-
await FullNodePeer.waitForConfirmation(
58-
updatedStoreInfo.coin.parentCoinInfo
59-
);
62+
console.log(
63+
`Updating store metadata with new root hash: ${newRootHash}, bytes: ${totalBytes}`
64+
);
65+
66+
const updatedStoreInfo = await dataStore.updateMetadata({
67+
...latestStore.metadata,
68+
rootHash: Buffer.from(newRootHash, "hex"),
69+
bytes: totalBytes,
70+
});
71+
72+
await FullNodePeer.waitForConfirmation(
73+
updatedStoreInfo.coin.parentCoinInfo
74+
);
75+
76+
await dataStore.fetchCoinInfo();
77+
}
6078

6179
await waitForPromise(
6280
() => dataStore.fetchCoinInfo(),

0 commit comments

Comments
 (0)