Skip to content

Commit

Permalink
Merge pull request #790 from oceanprotocol/issue-772-missing-code-hash
Browse files Browse the repository at this point in the history
recalculate code hash if needed
  • Loading branch information
paulo-ocean authored Dec 17, 2024
2 parents 2de7c25 + b3c26dc commit e42ada6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit e42ada6

Please sign in to comment.