Skip to content

Commit

Permalink
Merge pull request #23 from DIG-Network/release/v0.0.1-alpha.25
Browse files Browse the repository at this point in the history
Release/v0.0.1 alpha.25
  • Loading branch information
MichaelTaylor3D authored Sep 20, 2024
2 parents 0aa7e08 + 73bf1df commit 890f570
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 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.25](https://github.com/DIG-Network/dig-propagation-server/compare/v0.0.1-alpha.24...v0.0.1-alpha.25) (2024-09-20)

### [0.0.1-alpha.24](https://github.com/DIG-Network/dig-propagation-server/compare/v0.0.1-alpha.23...v0.0.1-alpha.24) (2024-09-20)

### [0.0.1-alpha.23](https://github.com/DIG-Network/dig-propagation-server/compare/v0.0.1-alpha.22...v0.0.1-alpha.23) (2024-09-20)
Expand Down
12 changes: 6 additions & 6 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": "dig-propagation-server",
"version": "0.0.1-alpha.24",
"version": "0.0.1-alpha.25",
"description": "",
"type": "commonjs",
"main": "./dist/index.js",
Expand All @@ -24,7 +24,7 @@
"LICENSE"
],
"dependencies": {
"@dignetwork/dig-sdk": "^0.0.1-alpha.46",
"@dignetwork/dig-sdk": "^0.0.1-alpha.48",
"async-mutex": "^0.5.0",
"chia-server-coin": "^0.0.5",
"express": "^4.19.2",
Expand Down
22 changes: 13 additions & 9 deletions src/tasks/sync_stores.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import fs from "fs";
import path from 'path';
import { SimpleIntervalJob, Task } from "toad-scheduler";
import {
getStoresList,
getManifestFilePath,
Wallet,
DataStore,
DigNetwork,
NconfManager,
ServerCoin
// @ts-ignore
ServerCoin,
STORE_PATH
} from "@dignetwork/dig-sdk";
import { Mutex } from "async-mutex";

Expand Down Expand Up @@ -42,19 +42,23 @@ const isStoreUpToDate = async (storeId: string): Promise<boolean> => {
const dataStore = await DataStore.from(storeId);

const rootHistory = await dataStore.getRootHistory();
const storePath = path.join(STORE_PATH, storeId);

const manifestFilePath = getManifestFilePath(storeId);
if (!fs.existsSync(manifestFilePath)) {
console.log(`Manifest file not found for store ${storeId}.`);
if (!fs.existsSync(storePath)) {
console.log(`Store path not found for store ${storeId}.`);
return false;
}

const manifest = fs.readFileSync(manifestFilePath, "utf-8").trim();
const manifestRootHashes = manifest.split("\n");
// Get the count of .dat files in the store directory
const datFiles = fs.readdirSync(storePath).filter(file => file.endsWith(".dat") && !file.includes('manifest'));
const datFileCount = datFiles.length;

return rootHistory.length === manifestRootHashes.length;
console.log(`Root history count: ${rootHistory.length}, .dat files count: ${datFileCount}`);

return rootHistory.length === datFileCount;
};


const syncStoreFromNetwork = async (storeId: string): Promise<void> => {
try {
console.log(`Attempting to sync store ${storeId} from the network...`);
Expand Down

0 comments on commit 890f570

Please sign in to comment.