Skip to content

Commit

Permalink
la
Browse files Browse the repository at this point in the history
  • Loading branch information
onmax committed Aug 19, 2024
1 parent 9a59e33 commit 04062c3
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions server/api/vts/health.get.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { max, count, } from 'drizzle-orm';
import { NimiqRPCClient } from 'nimiq-rpc-client-ts';
// import { NimiqRPCClient } from 'nimiq-rpc-client-ts';
// import { Range, getRange } from 'nimiq-vts';
import { getMissingEpochs } from '~~/server/database/utils';

Expand Down Expand Up @@ -32,8 +32,8 @@ export default defineEventHandler(async (event) => {
if (!url)
throw new Error('Missing RPC URL in runtime config')
console.log('RPC URL:', url)
const rpcClient = new NimiqRPCClient(new URL(url))
console.log('RPC Client:', rpcClient)
// const rpcClient = new NimiqRPCClient(new URL(url))
// console.log('RPC Client:', rpcClient)

// Get the latest epoch number in the activity table
const latestActivityBlock = await useDrizzle()
Expand All @@ -43,11 +43,11 @@ export default defineEventHandler(async (event) => {
.then((row) => row?.epoch ?? -1);
console.log('Latest Activity Block:', latestActivityBlock)

const { data: latestFetchedEpoch, error: errorLatestFetchedEpoch } = await rpcClient.policy.getEpochAt(latestActivityBlock)
if (errorLatestFetchedEpoch)
throw errorLatestFetchedEpoch;
console.log('Latest Fetched Epoch:', latestFetchedEpoch)
// const latestFetchedEpoch = latestActivityBlock
// const { data: latestFetchedEpoch, error: errorLatestFetchedEpoch } = await rpcClient.policy.getEpochAt(latestActivityBlock)
// if (errorLatestFetchedEpoch)
// throw errorLatestFetchedEpoch;
// console.log('Latest Fetched Epoch:', latestFetchedEpoch)
const latestFetchedEpoch = latestActivityBlock

// Get the total number of validators
const totalValidators = await useDrizzle()
Expand All @@ -66,14 +66,14 @@ export default defineEventHandler(async (event) => {
console.log('Fetched Epochs:', fetchedEpochs)


const { data: headBlockNumber, error: errorHeadBlockNumber } = await rpcClient.blockchain.getBlockNumber()
if (errorHeadBlockNumber)
throw errorHeadBlockNumber;
console.log('Head Block Number:', headBlockNumber)
const { data: currentEpoch, error: errorCurrentEpoch } = await rpcClient.blockchain.getEpochNumber()
if (errorCurrentEpoch)
throw errorCurrentEpoch;
console.log('Current Epoch:', currentEpoch)
// const { data: headBlockNumber, error: errorHeadBlockNumber } = await rpcClient.blockchain.getBlockNumber()
// if (errorHeadBlockNumber)
// throw errorHeadBlockNumber;
// console.log('Head Block Number:', headBlockNumber)
// const { data: currentEpoch, error: errorCurrentEpoch } = await rpcClient.blockchain.getEpochNumber()
// if (errorCurrentEpoch)
// throw errorCurrentEpoch;
// console.log('Current Epoch:', currentEpoch)

// const range = await getRange(rpcClient);
// console.log('Range:', range)
Expand All @@ -90,8 +90,8 @@ export default defineEventHandler(async (event) => {
const healthStatus: HealthStatus = {
latestFetchedEpoch,
totalValidators,
headBlockNumber,
currentEpoch,
headBlockNumber: 1111,
currentEpoch: 11,
range: {},
missingEpochs,
isSynced,
Expand Down

0 comments on commit 04062c3

Please sign in to comment.