mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 08:23:45 +00:00
feat: validate queue compatibility metadata
This commit is contained in:
@@ -15,14 +15,26 @@ const (
|
||||
RatingWidenPeriod = 30.0
|
||||
)
|
||||
|
||||
// QueueSpec is the compatibility contract selected by the authenticated
|
||||
// client. CandidateProviderV2 may use it to resolve a server-owned projection
|
||||
// from the verified account and current deployment configuration.
|
||||
type QueueSpec struct {
|
||||
Playlist Playlist
|
||||
ClientBuild string
|
||||
ProtocolVersion int
|
||||
}
|
||||
|
||||
// Candidate is the server-side projection of a verified, live queue ticket.
|
||||
// RTT values come from backend probes, never from the client request body.
|
||||
type Candidate struct {
|
||||
TicketID string
|
||||
PlayerID string
|
||||
Rating float64
|
||||
EnqueuedAt time.Time
|
||||
PredictedRTT map[string]float64
|
||||
TicketID string
|
||||
PlayerID string
|
||||
Playlist Playlist
|
||||
ClientBuild string
|
||||
ProtocolVersion int
|
||||
Rating float64
|
||||
EnqueuedAt time.Time
|
||||
PredictedRTT map[string]float64
|
||||
}
|
||||
|
||||
type Selection struct {
|
||||
|
||||
@@ -26,6 +26,7 @@ type QueueTicket struct {
|
||||
TicketID string
|
||||
PlayerID string
|
||||
Candidate Candidate
|
||||
Playlist Playlist
|
||||
State State
|
||||
Revision uint64
|
||||
EnqueuedAt time.Time
|
||||
@@ -70,7 +71,7 @@ func (q *Queue) Create(playerID, ticketID, idempotencyKey string, candidate Cand
|
||||
if _, ok := q.tickets[ticketID]; ok {
|
||||
return QueueTicket{}, fmt.Errorf("%w: ticket ID already exists", ErrConflict)
|
||||
}
|
||||
ticket := QueueTicket{TicketID: ticketID, PlayerID: playerID, Candidate: candidate, State: Queued, EnqueuedAt: now, ExpiresAt: now.Add(QueueExpiryWindow)}
|
||||
ticket := QueueTicket{TicketID: ticketID, PlayerID: playerID, Candidate: candidate, Playlist: candidate.Playlist, State: Queued, EnqueuedAt: now, ExpiresAt: now.Add(QueueExpiryWindow)}
|
||||
q.tickets[ticketID] = ticket
|
||||
q.byPlayer[playerID] = ticketID
|
||||
q.mutations[idempotencyKey] = queueMutation{digest: digest, ticket: ticket}
|
||||
|
||||
Reference in New Issue
Block a user