Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v0.0.1 alpha.112 #102

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

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.

### [0.0.1-alpha.112](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.111...v0.0.1-alpha.112) (2024-10-03)


### Bug Fixes

* double spend error ([3bed620](https://github.com/DIG-Network/dig-chia-sdk/commit/3bed620363e86979cfb2c3035cc7b4501a115b17))

### [0.0.1-alpha.111](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.110...v0.0.1-alpha.111) (2024-10-02)


Expand Down
86 changes: 43 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dignetwork/dig-sdk",
"version": "0.0.1-alpha.111",
"version": "0.0.1-alpha.112",
"description": "",
"type": "commonjs",
"main": "./dist/index.js",
Expand All @@ -25,7 +25,7 @@
"LICENSE"
],
"dependencies": {
"@dignetwork/datalayer-driver": "^0.1.28",
"@dignetwork/datalayer-driver": "^0.1.29",
"archiver": "^7.0.1",
"axios": "^1.7.7",
"bip39": "^3.1.0",
Expand Down
10 changes: 9 additions & 1 deletion src/DataIntegrityTree/DataIntegrityTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class DataIntegrityTree {
private storeBaseDir: string;
private storeDir: string;
private dataDir: string;
public files: Map<string, { hash: string; sha256: string }>;
public files: Map<string, { hash: string; sha256: string; bytes: string }>;
private tree: MerkleTree;

constructor(storeId: string, options: DataIntegrityTreeOptions = {}) {
Expand Down Expand Up @@ -208,13 +208,20 @@ class DataIntegrityTree {
}
const tempFilePath = path.join(tempDir, `${crypto.randomUUID()}.gz`);

let totalBytes = 0;

return new Promise((resolve, reject) => {
const tempWriteStream = fs.createWriteStream(tempFilePath);

readStream.on("data", (chunk) => {
uncompressedHash.update(chunk);
});

// Now listen to the gzip stream for compressed data size
gzip.on("data", (chunk) => {
totalBytes += chunk.length; // This counts compressed bytes
});

readStream.pipe(gzip).pipe(tempWriteStream);

tempWriteStream.on("finish", async () => {
Expand Down Expand Up @@ -255,6 +262,7 @@ class DataIntegrityTree {
this.files.set(key, {
hash: combinedHash,
sha256: sha256,
bytes: totalBytes.toString(),
});
await new Promise((resolve) => setTimeout(resolve, 100));
this._rebuildTree();
Expand Down
6 changes: 2 additions & 4 deletions src/DigNetwork/DigPeer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
} from "@dignetwork/datalayer-driver";
import { FullNodePeer } from "../blockchain";
import { Wallet } from "../blockchain";
import { selectUnspentCoins } from "../blockchain/coins";

export class DigPeer {
private ipAddress: string;
Expand Down Expand Up @@ -94,12 +93,11 @@ export class DigPeer {
(acc, output) => acc + output.amount,
BigInt(0)
);
const coins = await selectUnspentCoins(
const coins = await wallet.selectUnspentCoins(
peer,
totalAmount,
totalFee,
[],
walletName
[]
);

const coinSpends = await sendXch(
Expand Down
Loading
Loading