-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feat/add-block-cost-to-block-page
- Loading branch information
Showing
17 changed files
with
369 additions
and
72 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
api/src/models/api/nova/stats/slot/ISlotAnalyticStatsRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface ISlotAnalyticStatsRequest { | ||
/** | ||
* The network to search on. | ||
*/ | ||
network: string; | ||
|
||
/** | ||
* The slot index to get the stats for. | ||
*/ | ||
slotIndex: string; | ||
} |
12 changes: 12 additions & 0 deletions
12
api/src/models/api/nova/stats/slot/ISlotAnalyticStatsResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { IResponse } from "../../IResponse"; | ||
|
||
export interface ISlotAnalyticStatsResponse extends IResponse { | ||
slotIndex?: number; | ||
blockCount?: number; | ||
perPayloadType?: { | ||
transaction?: number; | ||
candidacy?: number; | ||
taggedData?: number; | ||
noPayload?: number; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { ServiceFactory } from "../../../../../factories/serviceFactory"; | ||
import { ISlotAnalyticStatsRequest } from "../../../../../models/api/nova/stats/slot/ISlotAnalyticStatsRequest"; | ||
import { ISlotAnalyticStatsResponse } from "../../../../../models/api/nova/stats/slot/ISlotAnalyticStatsResponse"; | ||
import { IConfiguration } from "../../../../../models/configuration/IConfiguration"; | ||
import { NOVA } from "../../../../../models/db/protocolVersion"; | ||
import { NetworkService } from "../../../../../services/networkService"; | ||
import { InfluxServiceNova } from "../../../../../services/nova/influx/influxServiceNova"; | ||
import { ValidationHelper } from "../../../../../utils/validationHelper"; | ||
|
||
/** | ||
* Fetch the slot stats from influx nova. | ||
* @param _ The configuration. | ||
* @param request The request. | ||
* @returns The response. | ||
*/ | ||
export async function get(_: IConfiguration, request: ISlotAnalyticStatsRequest): Promise<ISlotAnalyticStatsResponse> { | ||
const networkService = ServiceFactory.get<NetworkService>("network"); | ||
const networks = networkService.networkNames(); | ||
ValidationHelper.oneOf(request.network, networks, "network"); | ||
ValidationHelper.numberFromString(request.slotIndex, "slotIndex"); | ||
|
||
const networkConfig = networkService.get(request.network); | ||
|
||
if (networkConfig.protocolVersion !== NOVA) { | ||
return {}; | ||
} | ||
|
||
const influxService = ServiceFactory.get<InfluxServiceNova>(`influxdb-${networkConfig.network}`); | ||
|
||
if (influxService) { | ||
const slotIndex = Number.parseInt(request.slotIndex, 10); | ||
const slotStats = await influxService.getSlotAnalyticStats(slotIndex); | ||
|
||
if (slotStats) { | ||
return slotStats; | ||
} | ||
|
||
return { error: `Could not fetch stats for slot ${request.slotIndex}` }; | ||
} | ||
|
||
return { error: "Influx service not found for this network." }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.