Skip to content

Commit

Permalink
Update devPublicKey and newPOQReceipt if only exist and not the same
Browse files Browse the repository at this point in the history
  • Loading branch information
jairajdev committed Jun 25, 2024
1 parent 43b5add commit 7ea642b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export function updateConfig(newConfig: Partial<Config>): Config {
)
}
config = merge(config, newConfig)
Logger.mainLogger.info('Updated Archiver Config:', config)

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
return config
}

Expand Down
26 changes: 16 additions & 10 deletions src/Data/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,14 +552,20 @@ async function syncFromNetworkConfig(): Promise<any> {
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
Expand All @@ -576,8 +582,8 @@ async function getConsensusRadius(): Promise<number> {
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)
Expand Down

0 comments on commit 7ea642b

Please sign in to comment.