Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanfazakas committed Aug 7, 2024
1 parent 30d9155 commit 3fddbf6
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions src/components/core/utils/statusHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,25 @@ const platformInfo = {
node: process.version
}

async function getProviderInfo(config: OceanNodeConfig): Promise<any> {
const nodeStatus: any = {
provider: [],
indexer: []
}
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
}
nodeStatus.provider.push(provider)
providers.push(provider)
}
}
return nodeStatus
return providers
}

async function getIndexerInfo(
oceanNode: OceanNode,
config: OceanNodeConfig
): Promise<any> {
const nodeStatus: any = {
provider: [],
indexer: []
}
): Promise<OceanNodeIndexer[]> {
const indexerNetworks: OceanNodeIndexer[] = []
for (const [key, indexedNetwork] of Object.entries(config.indexingNetworks)) {
if (config.hasIndexer) {
const blockNr = await getIndexerBlockInfo(oceanNode, indexedNetwork)
Expand All @@ -83,10 +78,10 @@ async function getIndexerInfo(
network: indexedNetwork.network,
block: blockNr
}
nodeStatus.indexer.push(indexer)
indexerNetworks.push(indexer)
}
}
return nodeStatus
return indexerNetworks
}

async function getIndexerBlockInfo(
Expand Down Expand Up @@ -147,10 +142,8 @@ export async function status(

// need to update at least block info if available
if (config.supportedNetworks) {
const indexerInfo = await getIndexerInfo(oceanNode, config)
const providerInfo = await getProviderInfo(config)
nodeStatus.provider = providerInfo.provider
nodeStatus.indexer = indexerInfo.indexer
nodeStatus.provider = getProviderInfo(config)
nodeStatus.indexer = await getIndexerInfo(oceanNode, config)
}

// only these 2 might change between requests
Expand Down

0 comments on commit 3fddbf6

Please sign in to comment.