Skip to content

Commit

Permalink
Provider always enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiehewitt15 committed Aug 15, 2024
1 parent b18d45e commit c5f3769
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 17 deletions.
1 change: 0 additions & 1 deletion src/@types/OceanNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export interface OceanNodeConfig {
hasP2P: boolean
p2pConfig: OceanNodeP2PConfig | null
hasIndexer: boolean
hasProvider: boolean
hasHttp: boolean
hasDashboard: boolean
dbConfig?: OceanNodeDBConfig
Expand Down
10 changes: 4 additions & 6 deletions src/components/core/utils/statusHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@ const platformInfo = {
function getProviderInfo(config: OceanNodeConfig): OceanNodeProvider[] {
const providers: OceanNodeProvider[] = []
for (const [key, supportedNetwork] of Object.entries(config.supportedNetworks)) {
if (config.hasProvider) {
const provider: OceanNodeProvider = {
chainId: key,
network: supportedNetwork.network
}
providers.push(provider)
const provider: OceanNodeProvider = {
chainId: key,
network: supportedNetwork.network
}
providers.push(provider)
}
return providers
}
Expand Down
10 changes: 4 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,14 @@ if (!config) {
let node: OceanP2P = null
let indexer = null
let provider = null
let dbconn: Database | null = null
// If there is no DB connection only the nonce database will be available
const dbconn: Database | null = await new Database(config.dbConfig)

if (config.dbConfig?.url) {
if (!config.dbConfig?.url) {
// once we create a database instance, we check the environment and possibly add the DB transport
// after that, all loggers will eventually have it too (if in production/staging environments)
// it creates dinamically DDO schemas
dbconn = await new Database(config.dbConfig)
} else {
config.hasIndexer = false
config.hasProvider = false
}

if (config.hasP2P) {
Expand All @@ -115,7 +113,7 @@ if (config.hasIndexer && dbconn) {
}
}
}
if (config.hasProvider && dbconn) {
if (dbconn) {
provider = new OceanProvider(dbconn)
}

Expand Down
1 change: 0 additions & 1 deletion src/test/unit/ocean.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ describe('Status command tests', async () => {
expect(oceanNode.getDatabase()).to.not.eql(null)
expect(config.hasP2P).to.eql(true)
expect(config.hasIndexer).to.eql(true)
expect(config.hasProvider).to.eql(true)
})
it('Ocean P2P should be initialized correctly', () => {
expect(oceanNode.getP2PNode()).to.not.eql(null)
Expand Down
1 change: 0 additions & 1 deletion src/test/unit/oceanP2P.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ describe('OceanP2P Test without DB_URL set', () => {
assert(config, 'Failed to get P2P Node config')
assert(config.dbConfig.url === '', 'P2P Node config should not have DB URL set')
assert(config.hasIndexer === false, 'P2P Node should not have indexer enabled')
assert(config.hasProvider === false, 'P2P Node should not have provider enabled')
})
after(() => {
process.env.DB_URL = originalDBURL
Expand Down
2 changes: 0 additions & 2 deletions src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,6 @@ async function getEnvConfig(isStartup?: boolean): Promise<OceanNodeConfig> {
maxPeerAddrsToDial: getIntEnvValue(process.env.P2P_MAXPEERADDRSTODIAL, 5),
autoDialInterval: getIntEnvValue(process.env.P2P_AUTODIALINTERVAL, 5000)
},
// Only enable provider if we have a DB_URL
hasProvider: !!getEnvValue(process.env.DB_URL, ''),
hasDashboard: process.env.DASHBOARD !== 'false',
httpPort: getIntEnvValue(process.env.HTTP_API_PORT, 8000),
dbConfig: {
Expand Down

0 comments on commit c5f3769

Please sign in to comment.