diff --git a/CHANGELOG.md b/CHANGELOG.md index de89d39..b08699b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ 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.131](https://github.com/DIG-Network/dig-propagation-server/compare/v0.0.1-alpha.130...v0.0.1-alpha.131) (2024-10-08) + + +### Bug Fixes + +* check if store has roothash ([b277263](https://github.com/DIG-Network/dig-propagation-server/commit/b2772639f6159a9b13389f66d890ce2895fdbb31)) +* check if store has roothash ([f920566](https://github.com/DIG-Network/dig-propagation-server/commit/f920566ddf2c2ea5d898fdfda5be05836b4abef7)) + ### [0.0.1-alpha.130](https://github.com/DIG-Network/dig-propagation-server/compare/v0.0.1-alpha.129...v0.0.1-alpha.130) (2024-10-08) ### [0.0.1-alpha.129](https://github.com/DIG-Network/dig-propagation-server/compare/v0.0.1-alpha.128...v0.0.1-alpha.129) (2024-10-07) diff --git a/package-lock.json b/package-lock.json index 4719213..0483313 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "dig-propagation-server", - "version": "0.0.1-alpha.130", + "version": "0.0.1-alpha.131", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dig-propagation-server", - "version": "0.0.1-alpha.130", + "version": "0.0.1-alpha.131", "license": "ISC", "dependencies": { "@dignetwork/datalayer-driver": "^0.1.28", - "@dignetwork/dig-sdk": "^0.0.1-alpha.165", + "@dignetwork/dig-sdk": "^0.0.1-alpha.167", "async-mutex": "^0.5.0", "busboy": "^1.6.0", "express": "^4.19.2", @@ -252,9 +252,9 @@ } }, "node_modules/@dignetwork/dig-sdk": { - "version": "0.0.1-alpha.165", - "resolved": "https://registry.npmjs.org/@dignetwork/dig-sdk/-/dig-sdk-0.0.1-alpha.165.tgz", - "integrity": "sha512-mILuM0eVmuBU8QTw9L6xlRFVx+SMJUqdo30xExGxHyMmy6Yu0zJGkXla2mxZe8d3glEfsabjEZkwv2rHgl8TUQ==", + "version": "0.0.1-alpha.167", + "resolved": "https://registry.npmjs.org/@dignetwork/dig-sdk/-/dig-sdk-0.0.1-alpha.167.tgz", + "integrity": "sha512-t46nVGSRui9bLsmjx6LO/c8IOMDQI4Cy/S7vC4jRUT8CJconrHtGkL3BJ2v+NS8r/RbMHCJlnXDHdOm5c/T1sA==", "dependencies": { "@dignetwork/datalayer-driver": "^0.1.29", "@dignetwork/dig-sdk": "^0.0.1-alpha.158", diff --git a/package.json b/package.json index 765583b..4e0bd2c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dig-propagation-server", - "version": "0.0.1-alpha.130", + "version": "0.0.1-alpha.131", "description": "", "type": "commonjs", "main": "./dist/index.js", @@ -26,7 +26,7 @@ ], "dependencies": { "@dignetwork/datalayer-driver": "^0.1.28", - "@dignetwork/dig-sdk": "^0.0.1-alpha.165", + "@dignetwork/dig-sdk": "^0.0.1-alpha.167", "async-mutex": "^0.5.0", "busboy": "^1.6.0", "express": "^4.19.2", diff --git a/src/tasks/sync_stores.ts b/src/tasks/sync_stores.ts index ddfeefd..1cc3048 100644 --- a/src/tasks/sync_stores.ts +++ b/src/tasks/sync_stores.ts @@ -33,14 +33,19 @@ const checkedPeersMap: Map> = new Map(); const processPeer = async (peerIp: string, storeId: string, rootHash: string, checkedPeers: Set): Promise => { try { const digPeer = new DigPeer(peerIp, storeId); - const hasRootHash = await withTimeout(digPeer.contentServer.hasRootHash(rootHash), 15000, `Dig Peer: ${peerIp} took to long to respond to head request`); + const { storeExists, rootHashExists } = await withTimeout(digPeer.propagationServer.checkStoreExists(rootHash), 15000, `Dig Peer: ${peerIp} took to long to respond to head request`); - if (hasRootHash) { + if (!storeExists) { + console.log(`Dig Peer ${peerIp} does not have store ${storeId}. Skipping...`); + return; + } + + if (rootHashExists) { console.log(`Dig Peer ${peerIp} already has rootHash ${rootHash}. Marking as checked.`); checkedPeers.add(peerIp); // Mark as checked only if peer has the rootHash } else { console.log(`Dig Peer ${peerIp} does not have ${storeId}-${rootHash}. Pinging update.`); - await withTimeout( digPeer.propagationServer.pingUpdate(rootHash), 15000, `Dig Peer: ${peerIp} took to long to respond to ping request`); + await withTimeout(digPeer.propagationServer.pingUpdate(rootHash), 15000, `Dig Peer: ${peerIp} took to long to respond to ping request`); // Do NOT mark as checked if peer lacks the rootHash } } catch (error: any) {