Skip to content

Commit

Permalink
remove import function, dependency problem
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ocean committed Dec 9, 2024
1 parent 2359529 commit b3c26dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 3 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ declare global {
}
}

export async function recalculateCodeHash(): Promise<string> {
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const codeHash = await computeCodebaseHash(__dirname)
return codeHash
}
// we have 5 json examples
// we should have some DDO class too
function loadInitialDDOS(): any[] {
Expand Down Expand Up @@ -80,7 +74,9 @@ OCEAN_NODE_LOGGER.logMessageWithEmoji(
)

const config = await getConfiguration(true, isStartup)
config.codeHash = await recalculateCodeHash()
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
config.codeHash = await computeCodebaseHash(__dirname)

OCEAN_NODE_LOGGER.info(`Codebase hash: ${config.codeHash}`)
if (!config) {
Expand Down
8 changes: 6 additions & 2 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,7 +27,8 @@ import {
} from '../utils/address.js'
import { CONFIG_LOGGER } from './logging/common.js'
import { create256Hash } from './crypt.js'
import { recalculateCodeHash } from '..'
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 @@ -477,7 +479,9 @@ export async function getConfiguration(
previousConfiguration = await getEnvConfig(isStartup)
}
if (!previousConfiguration.codeHash) {
previousConfiguration.codeHash = await recalculateCodeHash()
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 b3c26dc

Please sign in to comment.