diff --git a/src/utils/config.ts b/src/utils/config.ts index 17d4fc020..b15d63df7 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -9,6 +9,7 @@ import { C2DClusterType } from '../@types/C2D.js' import { createFromPrivKey } from '@libp2p/peer-id-factory' import { keys } from '@libp2p/crypto' import { + computeCodebaseHash, DEFAULT_RATE_LIMIT_PER_SECOND, ENVIRONMENT_VARIABLES, EnvVariable, @@ -26,6 +27,8 @@ import { } from '../utils/address.js' import { CONFIG_LOGGER } from './logging/common.js' import { create256Hash } from './crypt.js' +import { fileURLToPath } from 'url' +import path from 'path' // usefull for lazy loading and avoid boilerplate on other places let previousConfiguration: OceanNodeConfig = null @@ -475,6 +478,12 @@ export async function getConfiguration( if (!previousConfiguration || forceReload) { previousConfiguration = await getEnvConfig(isStartup) } + if (!previousConfiguration.codeHash) { + const __filename = fileURLToPath(import.meta.url) + const __dirname = path.dirname(__filename.replace('utils/', '')) + previousConfiguration.codeHash = await computeCodebaseHash(__dirname) + } + return previousConfiguration }