Documentation
¶
Overview ¶
Package admin serves the voting-config endpoint by proxying the GitHub Pages CDN (valargroup/token-holder-voting-config).
Server registration, approval, and removal happen via GitHub PRs on the config repo — no write endpoints here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterRoutes ¶
RegisterRoutes registers admin HTTP routes on the given mux router.
func RegisterUIConfigRoutes ¶ added in v0.5.6
RegisterUIConfigRoutes registers GET /api/ui-config on the given router.
All values are resolved once at registration time from environment vars. Changing them requires a restart, which matches how the rest of the daemon reads its configuration.
Types ¶
type Admin ¶
type Admin struct {
// contains filtered or unexported fields
}
Admin fetches and caches the voting-config from the GitHub Pages CDN.
func (*Admin) GetVotingConfig ¶ added in v0.5.0
func (a *Admin) GetVotingConfig() (*VotingConfig, error)
GetVotingConfig returns the cached voting config, refreshing if stale.
type Config ¶
type Config struct {
// Disable turns off the admin server entirely.
Disable bool `mapstructure:"disable"`
// ConfigURL is the GitHub Pages CDN URL for the voting-config JSON.
ConfigURL string `mapstructure:"config_url"`
}
Config holds the admin server configuration, read from app.toml admin.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default admin configuration.
type ServiceEntry ¶
type ServiceEntry struct {
URL string `json:"url"`
Label string `json:"label"`
OperatorAddress string `json:"operator_address,omitempty"`
}
ServiceEntry is the wire format for a server in the voting-config response.
type UIConfigResponse ¶ added in v0.5.6
type UIConfigResponse struct {
// Mode is "dev" or "prod". The UI uses this to gate developer-only widgets.
Mode UIMode `json:"mode"`
// DevPIRControls is a denormalised flag for the most common gate so the UI
// does not need to know the meaning of each mode value.
DevPIRControls bool `json:"dev_pir_controls"`
// PrecomputedBaseURL is the bucket origin that this svoted's PIR siblings
// fetch their snapshots from. The UI composes the manifest URL as
// "<base>/snapshots/<height>/manifest.json" using a shared subpath
// constant. Resolved at startup from SVOTE_PRECOMPUTED_BASE_URL with a
// production-bucket default. Has no trailing slash.
PrecomputedBaseURL string `json:"precomputed_base_url"`
}
UIConfigResponse is the wire format returned by GET /api/ui-config.
It carries everything the static admin UI bundle needs to know about the svoted instance it's served by. New fields should be additive — older UI builds must continue to work against newer servers.
type UIMode ¶ added in v0.5.6
type UIMode string
UIMode controls which features the admin UI exposes.
"prod" hides developer-only controls such as the in-process PIR rebuild triggers. "dev" enables them. Production deployments must explicitly set SVOTE_UI_MODE=dev to opt in to the developer surface; the default is "prod" so a forgotten environment file can never accidentally expose them.
const ( UIModeProd UIMode = "prod" UIModeDev UIMode = "dev" // DefaultPrecomputedBaseURL is the production DigitalOcean Spaces bucket // where the publish-snapshot workflow uploads pre-computed PIR snapshots. // Per-deployment overrides go through SVOTE_PRECOMPUTED_BASE_URL so a // staging svoted can point at a staging bucket. DefaultPrecomputedBaseURL = "https://vote.fra1.digitaloceanspaces.com" )
type VotingConfig ¶
type VotingConfig struct {
Version int `json:"version"`
VoteServers []ServiceEntry `json:"vote_servers"`
PIRServers []ServiceEntry `json:"pir_endpoints"`
// SnapshotHeight is the canonical Orchard nullifier-tree snapshot height
// for the current voting round. PIR servers must serve this exact height,
// and the admin UI auto-populates round drafts from it.
SnapshotHeight *uint64 `json:"snapshot_height,omitempty"`
}
VotingConfig is the wire format returned by GET /api/voting-config.