[PR #1838] [MERGED] Telemetry server: the hub's votes (POST /hub/vote, GET /hub/votes) #3803

Closed
opened 2026-11-03 04:12:25 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1838
Author: @ludovic111
Created: 10/25/2026
Status: ✅ Merged
Merged: 10/25/2026
Merged by: @ludovic111

Base: main ← Head: feat/hub-votes


📝 Commits (2)

  • 5d40d6a Telemetry server: the hub's votes (POST /hub/vote, GET /hub/votes)
  • 91148cd Telemetry server: hub votes allow 600 an hour per address (bursts of 60)

📊 Changes

5 files changed (+388 additions, -6 deletions)

View changed files

📝 crates/horizon-telemetry-server/README.md (+6 -1)
➕ crates/horizon-telemetry-server/src/hub.rs (+239 -0)
📝 crates/horizon-telemetry-server/src/lib.rs (+25 -4)
📝 crates/horizon-telemetry-server/src/store.rs (+2 -1)
➕ crates/horizon-telemetry-server/tests/hub.rs (+116 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Part of the hub (playhorizon.dev/hub, #1815 → #1819 → #1821): the 👍 players give roadmap items. The website's buttons come in a later PR; the bug reports and suggestions are the next PR, stacked on this one.

  • POST /hub/vote {"item", "voter", "up"}: one vote per browser (voter is a random id the page keeps in localStorage), "up": false takes it back. It answers {"item", "votes"}.
  • GET /hub/votes: {"votes": {"<item>": n}}, rebuilt at most once a minute. A vote drops the cache.
  • Item ids are checked for shape (the roadmap's kebab-case ids, 48 characters at most), and the table takes at most 1000 distinct items, so nobody can fill it with made-up ids.
  • Rate limit: 600 an hour per address, bursts of 60 (HORIZON_TELEMETRY_HUB_PER_HOUR). Votes are cheap, and a school or a household shares one address. The end-to-end run showed a burst of 12 was too tight. The buckets are keyed by a hash of the address, with a key drawn at each start, kept in memory only. No address is stored.
  • OPTIONS answers the website's preflight (Access-Control-Allow-Origin is the website's, as for the other endpoints).

Stored: one row per vote (item id, random voter id). The take token bucket became generic over its key; nothing else in the server changes.

Deploy: not deployed. The coordinator deploys the telemetry server.

Self-check

In the crate's own workspace: cargo fmt --check, cargo clippy --all-targets -- -D warnings and cargo test are clean (lib 6, hub 2, live 5, server 9, summary 4).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/1838 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/hub-votes` --- ### 📝 Commits (2) - [`5d40d6a`](https://github.com/horizon-rust/horizon/commit/5d40d6a33ea36d07440d4eecf03ab63028eff3f6) Telemetry server: the hub's votes (POST /hub/vote, GET /hub/votes) - [`91148cd`](https://github.com/horizon-rust/horizon/commit/91148cdf74b18741253bfcc20313c0f239a4c3b6) Telemetry server: hub votes allow 600 an hour per address (bursts of 60) ### 📊 Changes **5 files changed** (+388 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-telemetry-server/README.md` (+6 -1) ➕ `crates/horizon-telemetry-server/src/hub.rs` (+239 -0) 📝 `crates/horizon-telemetry-server/src/lib.rs` (+25 -4) 📝 `crates/horizon-telemetry-server/src/store.rs` (+2 -1) ➕ `crates/horizon-telemetry-server/tests/hub.rs` (+116 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Part of the hub (playhorizon.dev/hub, #1815 → #1819 → #1821): the 👍 players give roadmap items. The website's buttons come in a later PR; the bug reports and suggestions are the next PR, stacked on this one. - `POST /hub/vote` `{"item", "voter", "up"}`: one vote per browser (`voter` is a random id the page keeps in localStorage), `"up": false` takes it back. It answers `{"item", "votes"}`. - `GET /hub/votes`: `{"votes": {"<item>": n}}`, rebuilt at most once a minute. A vote drops the cache. - Item ids are checked for shape (the roadmap's kebab-case ids, 48 characters at most), and the table takes at most 1000 distinct items, so nobody can fill it with made-up ids. - Rate limit: 600 an hour per address, bursts of 60 (`HORIZON_TELEMETRY_HUB_PER_HOUR`). Votes are cheap, and a school or a household shares one address. The end-to-end run showed a burst of 12 was too tight. The buckets are keyed by a hash of the address, with a key drawn at each start, kept in memory only. No address is stored. - `OPTIONS` answers the website's preflight (`Access-Control-Allow-Origin` is the website's, as for the other endpoints). Stored: one row per vote (item id, random voter id). The `take` token bucket became generic over its key; nothing else in the server changes. **Deploy:** not deployed. The coordinator deploys the telemetry server. ### Self-check In the crate's own workspace: `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings` and `cargo test` are clean (lib 6, hub 2, live 5, server 9, summary 4). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:12:25 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#3803
No description provided.