From 7ea642bd80df156c72e181f81771f45be208b137 Mon Sep 17 00:00:00 2001 From: jairajdev Date: Tue, 25 Jun 2024 12:51:49 +0545 Subject: [PATCH] Update devPublicKey and newPOQReceipt if only exist and not the same --- src/Config.ts | 1 + src/Data/Data.ts | 26 ++++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/Config.ts b/src/Config.ts index 1d49d0e6..a8120034 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -252,6 +252,7 @@ export function updateConfig(newConfig: Partial): Config { ) } config = merge(config, newConfig) + Logger.mainLogger.info('Updated Archiver Config:', config) return config } diff --git a/src/Data/Data.ts b/src/Data/Data.ts index 38a1d3c4..373e7b92 100644 --- a/src/Data/Data.ts +++ b/src/Data/Data.ts @@ -552,14 +552,20 @@ async function syncFromNetworkConfig(): Promise { if (tallyItem?.value?.config) { // Updating the Archiver Config as per the latest Network Config const devPublicKeys = tallyItem.value.config?.devPublicKeys - const updateConfigProps = { - newPOQReceipt: tallyItem.value.config?.useNewPOQ, - DevPublicKey: - devPublicKeys && Object.keys(devPublicKeys).length >= 3 - ? Object.keys(devPublicKeys).find((key) => devPublicKeys[key] === 3) - : '', - } - updateConfig(updateConfigProps) + const devPublicKey = devPublicKeys && Object.keys(devPublicKeys).length >= 3 && devPublicKeys[3] + const newPOQReceipt = tallyItem.value.config?.useNewPOQ + if ( + devPublicKey && + typeof devPublicKey === typeof config.DevPublicKey && + devPublicKey !== config.DevPublicKey + ) + updateConfig({ DevPublicKey: devPublicKey }) + if ( + newPOQReceipt !== null && + typeof newPOQReceipt === typeof config.newPOQReceipt && + newPOQReceipt !== config.newPOQReceipt + ) + updateConfig({ newPOQReceipt }) return tallyItem } return null @@ -576,8 +582,8 @@ async function getConsensusRadius(): Promise { const tallyItem = await syncFromNetworkConfig() // Check if a consensus was reached if (tallyItem?.value?.config) { - nodesPerEdge = tallyItem.value.config.sharding.nodesPerEdge - nodesPerConsensusGroup = tallyItem.value.config.sharding.nodesPerConsensusGroup + nodesPerEdge = tallyItem.value.config.sharding?.nodesPerEdge + nodesPerConsensusGroup = tallyItem.value.config?.sharding.nodesPerConsensusGroup if (!Number.isInteger(nodesPerConsensusGroup) || nodesPerConsensusGroup <= 0) { Logger.mainLogger.error('nodesPerConsensusGroup is not a valid number:', nodesPerConsensusGroup)