Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import { MemoryNonceStore, PostgresNonceStore, type NonceStore } from '../auth.j
import { readFileSync } from 'fs'
import { dirname, join } from 'path'
import { fileURLToPath } from 'url'
// Stellar's nominal ledger close time, used to convert a lag in ledgers into
// an estimated lag in seconds for the /ready readiness probe.
const STELLAR_LEDGER_CLOSE_TIME_SECONDS = 5

interface CursorRow {
last_ledger: number | null
Expand Down Expand Up @@ -141,7 +144,7 @@ export async function buildServer(opts: BuildServerOptions = {}): Promise<Fastif
const ledgersBehind = lastLedger != null && tipLedger != null && tipLedger > lastLedger
? tipLedger - lastLedger
: null
const estimatedLagSeconds = ledgersBehind != null ? ledgersBehind * 5 : null
const estimatedLagSeconds = ledgersBehind != null ? ledgersBehind * STELLAR_LEDGER_CLOSE_TIME_SECONDS : null

if (isStale) {
return reply.code(503).send({
Expand Down