ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
election.h
Go to the documentation of this file.
1
5
6#pragma once
7
9#include <stdbool.h>
10#include <stdint.h>
11#include "metrics.h"
12#include <ascii-chat/common.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
28uint32_t consensus_election_compute_score(const participant_metrics_t *metrics);
29
36asciichat_error_t consensus_election_choose_hosts(const participant_metrics_t *metrics, int num_metrics,
37 int *out_best_index, // Index of best host
38 int *out_backup_index // Index of backup host
39);
40
47asciichat_error_t consensus_election_verify(const participant_metrics_t *metrics, int num_metrics, const uint8_t announced_host_id[SESSION_ID_SIZE], const uint8_t announced_backup_id[SESSION_ID_SIZE],
48 bool *out_valid);
49
50#ifdef __cplusplus
51}
52#endif
uint32_t consensus_election_compute_score(const participant_metrics_t *metrics)
Compute deterministic score for a participant.
Definition election.c:14
asciichat_error_t consensus_election_verify(const participant_metrics_t *metrics, int num_metrics, const uint8_t announced_host_id[SESSION_ID_SIZE], const uint8_t announced_backup_id[SESSION_ID_SIZE], bool *out_valid)
Verify election result matches expected scores.
Definition election.c:105
asciichat_error_t consensus_election_choose_hosts(const participant_metrics_t *metrics, int num_metrics, int *out_best_index, int *out_backup_index)
Elect best and backup host from metrics.
Definition election.c:78
unsigned int uint32_t
unsigned char uint8_t
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
#define SESSION_ID_SIZE
⚙️ Common definitions, error codes, macros, and types shared throughout the application
Ring consensus metrics collection and wire protocol.