Skip to content

Commit

Permalink
Merge pull request #108 from DIG-Network/release/v0.0.1-alpha.119
Browse files Browse the repository at this point in the history
Release/v0.0.1 alpha.119
  • Loading branch information
MichaelTaylor3D authored Oct 3, 2024
2 parents 6a4635f + 0a9c0e3 commit 89a4fb2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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.119](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.118...v0.0.1-alpha.119) (2024-10-03)

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

### [0.0.1-alpha.117](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.116...v0.0.1-alpha.117) (2024-10-03)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion 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.118",
"version": "0.0.1-alpha.119",
"description": "",
"type": "commonjs",
"main": "./dist/index.js",
Expand Down
34 changes: 26 additions & 8 deletions src/blockchain/StoreInfoCacheUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Peer,
getMainnetGenesisChallenge,
} from "@dignetwork/datalayer-driver";
import { get } from "lodash";

export class StoreInfoCacheUpdater {
private static instance: StoreInfoCacheUpdater;
Expand Down Expand Up @@ -52,7 +53,7 @@ export class StoreInfoCacheUpdater {
private async startMonitors() {
try {
console.log("Checking if lockfile exists...");

// Check if the lock file exists
if (!fs.existsSync(this.lockFilePath)) {
console.log("Lockfile does not exist. Proceeding without lock.");
Expand Down Expand Up @@ -80,7 +81,7 @@ export class StoreInfoCacheUpdater {
});

console.log("Lock acquired, starting monitors...");

// Renew the lock every minute by reacquiring it
this.renewLock();

Expand Down Expand Up @@ -190,12 +191,29 @@ export class StoreInfoCacheUpdater {

console.log(`Waiting for coin to be spent: ${coinId.toString("hex")}`);

// Wait for the coin to be spent
await peer.waitForCoinToBeSpent(
coinId,
latestHeight,
Buffer.from(latestHash, "hex")
);
try {
// Wait for the coin to be spent
await peer.waitForCoinToBeSpent(
coinId,
latestHeight,
Buffer.from(latestHash, "hex")
);
} catch {
const genesisChallenge = await getMainnetGenesisChallenge();
const storeInfo = await withTimeout(
peer.syncStore(latestStore, null, genesisChallenge, false),
60000,
`Timeout syncing store for storeId ${storeId}`
);

const headerHash = await peer.getHeaderHash(storeInfo.latestHeight);

await peer.waitForCoinToBeSpent(
getCoinId(storeInfo.latestStore.coin),
storeInfo.latestHeight,
headerHash
);
}

console.log(`Detected Coin Spend: ${coinId.toString("hex")}`);

Expand Down

0 comments on commit 89a4fb2

Please sign in to comment.