Skip to content

Implement binary serialization for prestats and frontend adaptation - #151

Merged
Flash303 merged 3 commits into
devfrom
opt/binary-prestats
Nov 8, 2026
Merged

Flash303 merged 3 commits into
devfrom
opt/binary-prestats

Conversation

@Flash303

@Flash303 Flash303 commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Serve server-list prestats in the same binary format as GET /records/{id}, base64-encoded in a new stats_data field instead of JSON.

Backend:

  • BiggerServerResponse.data: Option → stats_data: Option<Vec>, serialized as base64 (serialize_opt_base64)
  • Reuses the existing RecordData::into_binary layout (u32 count + i64 base + N×u32 deltas + N×i32 values, LE)

Frontend:

  • New shared decoder api/records-binary.ts (parseRecordBinary, base64ToArrayBuffer, decodeStatsBase64), now used by both fetchRecords and normalizeServerData
  • normalizeServerData converts stats_data → data: ServerRecord[] and strips the base64 payload; legacy [dates, values] tuple still supported
  • Values now read as i32 to match the backend layout
  • 10 new tests (records-binary.test.ts): round-trip, empty/truncated buffers, invalid base64, legacy tuple
    Payload win: prestats no longer pay the JSON number-array overhead on /servers?include_stats=true.

@Flash303
Flash303 merged commit 8e5b9ac into dev Nov 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant