Skip to content

Commit 26590bb

Browse files
Merge pull request #111 from DIG-Network/release/v0.0.1-alpha.122
Release/v0.0.1 alpha.122
2 parents bf5c007 + 76e2c58 commit 26590bb

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
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.122](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.121...v0.0.1-alpha.122) (2024-10-04)
6+
7+
8+
### Bug Fixes
9+
10+
* additional logging ([d21b141](https://github.com/DIG-Network/dig-chia-sdk/commit/d21b1411d69a4a667279216aa906daef7203a02f))
11+
512
### [0.0.1-alpha.121](https://github.com/DIG-Network/dig-chia-sdk/compare/v0.0.1-alpha.120...v0.0.1-alpha.121) (2024-10-03)
613

714

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.121",
3+
"version": "0.0.1-alpha.122",
44
"description": "",
55
"type": "commonjs",
66
"main": "./dist/index.js",

src/blockchain/DataStore.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ export class DataStore {
324324
public static async monitorStoreIndefinitely(storeId: string): Promise<void> {
325325
// Check if a monitor is already running for this storeId
326326
if (this.activeMonitors.get(storeId)) {
327-
console.log(`Monitor already running for storeId: ${storeId}`);
327+
console.log("Monitor:", `Monitor already running for storeId: ${storeId}`);
328328
return;
329329
}
330330

@@ -338,19 +338,19 @@ export class DataStore {
338338
}>(`stores`);
339339

340340
// Clear the cache at the start
341-
console.log(`Clearing cache for storeId: ${storeId}`);
341+
console.log("Monitor:", `Clearing cache for storeId: ${storeId}`);
342342
storeCoinCache.delete(storeId);
343343

344344
while (true) {
345345
try {
346-
console.log(`Connecting to peer for storeId: ${storeId}`);
346+
console.log("Monitor:", `Connecting to peer for storeId: ${storeId}`);
347347
const peer = await FullNodePeer.connect();
348348
const cachedInfo = storeCoinCache.get(storeId);
349349

350350
if (cachedInfo) {
351351
// Log cached store info retrieval
352352
console.log(
353-
`Cached store info found for storeId: ${storeId}, syncing...`
353+
"Monitor:", `Cached store info found for storeId: ${storeId}, syncing...`
354354
);
355355

356356
// Deserialize cached info and wait for the coin to be spent
@@ -361,16 +361,20 @@ export class DataStore {
361361
});
362362

363363
console.log(
364-
`Waiting for coin to be spent for storeId: ${storeId}...`
364+
"Monitor:", `Waiting for coin to be spent for storeId: ${storeId}...`
365365
);
366+
367+
const dataStore = DataStore.from(storeId);
368+
const { createdAtHeight, createdAtHash } = await dataStore.getCreationHeight();
369+
366370
await peer.waitForCoinToBeSpent(
367371
getCoinId(previousStore.latestStore.coin),
368-
previousStore.latestHeight,
369-
previousStore.latestHash
372+
createdAtHeight,
373+
createdAtHash
370374
);
371375

372376
// Sync store and get updated details
373-
console.log(`Syncing store for storeId: ${storeId}`);
377+
console.log("Monitor:", `Syncing store for storeId: ${storeId}`);
374378
const { latestStore, latestHeight } = await peer.syncStore(
375379
previousStore.latestStore,
376380
previousStore.latestHeight,
@@ -386,7 +390,7 @@ export class DataStore {
386390
latestHash
387391
).serialize();
388392

389-
console.log(`Caching updated store info for storeId: ${storeId}`);
393+
console.log("Monitor:", `Caching updated store info for storeId: ${storeId}`);
390394
storeCoinCache.set(storeId, {
391395
latestStore: serializedLatestStore,
392396
latestHeight,
@@ -398,14 +402,14 @@ export class DataStore {
398402

399403
// If no cached info exists, log and sync from the creation height
400404
console.log(
401-
`No cached info found for storeId: ${storeId}. Retrieving creation height.`
405+
"Monitor:", `No cached info found for storeId: ${storeId}. Retrieving creation height.`
402406
);
403407

404408
const dataStore = DataStore.from(storeId);
405409
const { createdAtHeight, createdAtHash } = await dataStore.getCreationHeight();
406410

407411
// Sync store from the peer using launcher ID
408-
console.log(`Syncing store from launcher ID for storeId: ${storeId}`);
412+
console.log("Monitor:", `Syncing store from launcher ID for storeId: ${storeId}`);
409413
const { latestStore, latestHeight } = await peer.syncStoreFromLauncherId(
410414
Buffer.from(storeId, "hex"),
411415
createdAtHeight,
@@ -422,15 +426,15 @@ export class DataStore {
422426
latestHash
423427
).serialize();
424428

425-
console.log(`Caching new store info for storeId: ${storeId}`);
429+
console.log("Monitor:", `Caching new store info for storeId: ${storeId}`);
426430
storeCoinCache.set(storeId, {
427431
latestStore: serializedLatestStore,
428432
latestHeight,
429433
latestHash: latestHash.toString("hex"),
430434
});
431435
} catch (error: any) {
432436
console.error(
433-
`Error in monitorStoreIndefinitely for storeId: ${storeId} - ${error.message}`
437+
"Monitor:", `Error in monitorStoreIndefinitely for storeId: ${storeId} - ${error.message}`
434438
);
435439

436440
// Delay before restarting to avoid rapid retries

0 commit comments

Comments
 (0)