-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use validators.app info for mainnet ping chart (#414)
# Changes to Note - Mainnet ping chart is now provided as the median confirmation time for transactions as reported by [validators.app](https://www.validators.app/ping-thing?locale=en&network=mainnet) Not a change, but worth calling out- TPS chart timing has never been 1-1 with ping information because TPS and Ping signals have different sampling rates
- Loading branch information
Showing
4 changed files
with
416 additions
and
13 deletions.
There are no files selected for viewing
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,49 @@ | ||
import { fetch } from 'cross-fetch'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
type Params = { | ||
params: { | ||
network: 'mainnet'; | ||
}; | ||
}; | ||
|
||
export type ValidatorsAppPingStats = { | ||
interval: number; | ||
max: number; | ||
median: number; | ||
min: number; | ||
network: string; | ||
num_of_records: number; | ||
time_from: string; | ||
average_slot_latency: number; | ||
tps: number; | ||
}; | ||
|
||
const PING_INTERVALS: number[] = [1, 3, 12]; | ||
|
||
export async function GET(_request: Request, { params: { network } }: Params) { | ||
const responses = await Promise.all( | ||
PING_INTERVALS.map(interval => | ||
fetch(`https://www.validators.app/api/v1/ping-thing-stats/${network}.json?interval=${interval}`, { | ||
cache: 'no-store', | ||
headers: { | ||
'Cache-Control': 'no-store, max-age=0', | ||
Token: process.env.PING_API_KEY || '', | ||
}, | ||
}) | ||
) | ||
); | ||
const data: { [interval: number]: ValidatorsAppPingStats[] } = {}; | ||
await Promise.all( | ||
responses.map(async (response, index) => { | ||
const interval = PING_INTERVALS[index]; | ||
data[interval] = await response.json(); | ||
}) | ||
); | ||
|
||
return NextResponse.json(data, { | ||
headers: { | ||
'Cache-Control': 'public, max-age=30', | ||
}, | ||
}); | ||
} |
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.