Skip to content

Commit 7cbb8bc

Browse files
authored
Merge pull request #619 from oceanprotocol/issue-618-provider-fix
Provider always enabled
2 parents b18d45e + 0340247 commit 7cbb8bc

File tree

6 files changed

+8
-17
lines changed

6 files changed

+8
-17
lines changed

src/@types/OceanNode.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export interface OceanNodeConfig {
6060
hasP2P: boolean
6161
p2pConfig: OceanNodeP2PConfig | null
6262
hasIndexer: boolean
63-
hasProvider: boolean
6463
hasHttp: boolean
6564
hasDashboard: boolean
6665
dbConfig?: OceanNodeDBConfig

src/components/core/utils/statusHandler.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@ const platformInfo = {
5454
function getProviderInfo(config: OceanNodeConfig): OceanNodeProvider[] {
5555
const providers: OceanNodeProvider[] = []
5656
for (const [key, supportedNetwork] of Object.entries(config.supportedNetworks)) {
57-
if (config.hasProvider) {
58-
const provider: OceanNodeProvider = {
59-
chainId: key,
60-
network: supportedNetwork.network
61-
}
62-
providers.push(provider)
57+
const provider: OceanNodeProvider = {
58+
chainId: key,
59+
network: supportedNetwork.network
6360
}
61+
providers.push(provider)
6462
}
6563
return providers
6664
}

src/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,14 @@ if (!config) {
8080
let node: OceanP2P = null
8181
let indexer = null
8282
let provider = null
83-
let dbconn: Database | null = null
83+
// If there is no DB URL only the nonce database will be available
84+
const dbconn: Database = await new Database(config.dbConfig)
8485

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

9593
if (config.hasP2P) {
@@ -115,7 +113,7 @@ if (config.hasIndexer && dbconn) {
115113
}
116114
}
117115
}
118-
if (config.hasProvider && dbconn) {
116+
if (dbconn) {
119117
provider = new OceanProvider(dbconn)
120118
}
121119

src/test/unit/ocean.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ describe('Status command tests', async () => {
5757
expect(oceanNode.getDatabase()).to.not.eql(null)
5858
expect(config.hasP2P).to.eql(true)
5959
expect(config.hasIndexer).to.eql(true)
60-
expect(config.hasProvider).to.eql(true)
6160
})
6261
it('Ocean P2P should be initialized correctly', () => {
6362
expect(oceanNode.getP2PNode()).to.not.eql(null)

src/test/unit/oceanP2P.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ describe('OceanP2P Test without DB_URL set', () => {
117117
assert(config, 'Failed to get P2P Node config')
118118
assert(config.dbConfig.url === '', 'P2P Node config should not have DB URL set')
119119
assert(config.hasIndexer === false, 'P2P Node should not have indexer enabled')
120-
assert(config.hasProvider === false, 'P2P Node should not have provider enabled')
121120
})
122121
after(() => {
123122
process.env.DB_URL = originalDBURL

src/utils/config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,6 @@ async function getEnvConfig(isStartup?: boolean): Promise<OceanNodeConfig> {
542542
maxPeerAddrsToDial: getIntEnvValue(process.env.P2P_MAXPEERADDRSTODIAL, 5),
543543
autoDialInterval: getIntEnvValue(process.env.P2P_AUTODIALINTERVAL, 5000)
544544
},
545-
// Only enable provider if we have a DB_URL
546-
hasProvider: !!getEnvValue(process.env.DB_URL, ''),
547545
hasDashboard: process.env.DASHBOARD !== 'false',
548546
httpPort: getIntEnvValue(process.env.HTTP_API_PORT, 8000),
549547
dbConfig: {

0 commit comments

Comments
 (0)