Skip to content

Commit f1add00

Browse files
Merge pull request #150 from DIG-Network/release/v0.0.1-alpha.166
Release/v0.0.1 alpha.166
2 parents e5f75d8 + 5a900d5 commit f1add00

File tree

5 files changed

+16
-32
lines changed

5 files changed

+16
-32
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
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.166](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.165...v0.0.1-alpha.166) (2024-10-08)
6+
7+
8+
### Bug Fixes
9+
10+
* get coin state to the right folder ([050586c](https://github.com/DIG-Network/dig-chia-sdk/commit/050586cd1d25f4ce0ce98128f519e390303834ee))
11+
* wait for confirmation ([dc704ad](https://github.com/DIG-Network/dig-chia-sdk/commit/dc704ad32390de2a9252206b4a6dc38e110319dc))
12+
513
### [0.0.1-alpha.165](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.164...v0.0.1-alpha.165) (2024-10-08)
614

715

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dignetwork/dig-sdk",
3-
"version": "0.0.1-alpha.165",
3+
"version": "0.0.1-alpha.166",
44
"description": "",
55
"type": "commonjs",
66
"main": "./dist/index.js",

src/blockchain/FullNodePeer.ts

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,7 @@ export class FullNodePeer {
293293
private static initializePeerWeights(peerIPs: string[]): void {
294294
for (const ip of peerIPs) {
295295
if (!FullNodePeer.peerWeights.has(ip)) {
296-
if (
297-
ip === LOCALHOST ||
298-
ip === FullNodePeer.getTrustedFullNode()
299-
) {
296+
if (ip === LOCALHOST || ip === FullNodePeer.getTrustedFullNode()) {
300297
FullNodePeer.peerWeights.set(ip, 5); // Higher weight for prioritized peers
301298
} else {
302299
FullNodePeer.peerWeights.set(ip, 1); // Default weight
@@ -518,40 +515,19 @@ export class FullNodePeer {
518515
parentCoinInfo: Buffer
519516
): Promise<boolean> {
520517
const spinner = createSpinner("Waiting for confirmation...").start();
521-
let peer: Peer;
522-
523-
try {
524-
peer = await FullNodePeer.connect();
525-
} catch (error: any) {
526-
spinner.error({ text: "Failed to connect to a fullnode peer." });
527-
console.error(`waitForConfirmation connection error: ${error.message}`);
528-
throw error;
529-
}
530-
531-
// Extract peer IP to access the corresponding limiter
532-
const peerIP = FullNodePeer.extractPeerIP(peer);
533-
if (!peerIP) {
534-
spinner.error({ text: "Failed to extract fullnode peer IP." });
535-
throw new Error("Failed to extract peer IP.");
536-
}
518+
const peer = await FullNodePeer.connect();
537519

538520
try {
539521
while (true) {
540522
// Schedule the isCoinSpent method call through the limiter
541523

542-
const confirmed = await peer.isCoinSpent(
524+
await peer.waitForCoinToBeSpent(
543525
parentCoinInfo,
544526
MIN_HEIGHT,
545527
Buffer.from(MIN_HEIGHT_HEADER_HASH, "hex")
546528
);
547529

548-
if (confirmed) {
549-
spinner.success({ text: "Coin confirmed!" });
550-
return true;
551-
}
552-
553-
// Wait for 5 seconds before the next check
554-
await new Promise((resolve) => setTimeout(resolve, 5000));
530+
spinner.success({ text: "Coin confirmed!" });
555531
}
556532
} catch (error: any) {
557533
spinner.error({ text: "Error while waiting for confirmation." });

src/utils/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const getCoinState = (
8181
description: string;
8282
};
8383
} => {
84-
const stateFile = path.join(STORE_PATH, `${storeId}.json`);
84+
const stateFile = path.join(USER_DIR_PATH, `${storeId}.json`);
8585
if (!fs.existsSync(stateFile)) {
8686
return {
8787
metadata: { rootHash: "", bytes: "", label: "", description: "" },

0 commit comments

Comments
 (0)