mirror of
https://github.com/luxfi/explore.git
synced 2026-10-30 16:57:53 +00:00
luxd serves no P-Chain JSON-RPC, so every platform.* read the explorer sent
answered 404 and the validators, chains and heights widgets were empty on Lux
and Zoo. Each read is now GET /v1/chain/P/ops/{validators,blockchains,height},
coded against the node's OpenAPI 3.1 document, through GET
/v1/node/p-chain?op=<op>. The proxy's fixed table allows those three ops and one
NodeID parameter; a POST there answers 405.
ChainEntry.pChain is where the P-Chain that secures a chain is read: Lux reads
its own; Zoo, an L2 carried by Lux's validator set, reads Lux's and never its
own node's; Hanzo, on its own committee until hanzod joins as an L2, has none.
P-Chain UI names whose it is ("Lux primary network validators securing Zoo
Network") and prices stake in LUX. The cross-network validator sum is gone: it
counted Lux's validators again under Zoo.
The top bar shows a link only where its page has content: Chains, Bridge and
DEX on the Lux C-Chain host (their pages now 404 elsewhere), Validators where a
P-Chain secures the chain, Stats where there is a P-Chain panel or a stats
service. A P-Chain at genesis renders height #0 rather than nothing. The chain
page's uptime is no longer multiplied by 100.
Claude-Session: https://claude.ai/code/session_011Ge9UnfkEK37Lapx5nfPQK
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
// How much we actually know about a trading venue. Every word already carries
|
|
// this meaning elsewhere in the codebase (lib/api/cchain/useFeeSplit) and keeps
|
|
// it here:
|
|
//
|
|
// 'unavailable' — the indexer never answered, so we learned nothing at all.
|
|
// 'unknown' — it answered, but the chain head is unreadable, so we cannot
|
|
// judge how recent its newest trade is.
|
|
// 'empty' — it answered and has never recorded a single trade.
|
|
// 'idle' — it has history, but nothing inside the recent window.
|
|
// 'live' — its newest trade is inside the recent window.
|
|
//
|
|
// There is deliberately no 'stale'. Telling a stalled indexer apart from a
|
|
// quiet venue needs the indexer's own head block, which this API does not
|
|
// serve, so claiming that distinction would be a guess.
|
|
export type VenueStatus = 'live' | 'idle' | 'empty' | 'unavailable' | 'unknown';
|
|
|
|
// ~30 minutes at the ~9s cadence C-Chain actually runs.
|
|
export const RECENT_WINDOW_BLOCKS = 200;
|
|
|
|
export function deriveVenueStatus(
|
|
latestBlock: number | null,
|
|
headBlock: number | null,
|
|
reachable: boolean,
|
|
): VenueStatus {
|
|
if (!reachable) {
|
|
return 'unavailable';
|
|
}
|
|
|
|
if (latestBlock === null) {
|
|
return 'empty';
|
|
}
|
|
|
|
if (headBlock === null) {
|
|
return 'unknown';
|
|
}
|
|
|
|
return headBlock - latestBlock <= RECENT_WINDOW_BLOCKS ? 'live' : 'idle';
|
|
}
|