ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
handoff.h
Go to the documentation of this file.
2#include <ascii-chat/common.h>
3#pragma once
4
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11/* Versioned control frames. Integer fields are explicitly encoded, never cast
12 * from transport buffers. All deadlines belong to the receiver's clock. */
13#define CONSENSUS_HANDOFF_PACKET 6090
14#define CONSENSUS_HANDOFF_VERSION 1
15#define CONSENSUS_HANDOFF_HEADER 64
16#define CONSENSUS_HANDOFF_PROBE_BYTES 65536
17#define CONSENSUS_HANDOFF_FRESH_MS 15000
18#define CONSENSUS_HANDOFF_PREPARE_MS 5000
19#define CONSENSUS_HANDOFF_RECOVERY_MS 15000
20
32
47
71
97
103/* Caller authenticates participant/session against the transport identity. */
105/* Returns one action, or false when the state is unchanged. */
107
108/* Caller authenticates the reporter; obsolete host reports are ignored. */
110
111#ifdef __cplusplus
112}
113#endif
Deterministic host election algorithm.
unsigned short uint16_t
unsigned int uint32_t
unsigned long long uint64_t
unsigned char uint8_t
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
#define MAX_SESSION_PARTICIPANTS
#define SESSION_ID_SIZE
bool consensus_handoff_tick(consensus_handoff_t *state, uint64_t now_ms, consensus_handoff_message_t *action)
Advance measured successor selection and bounded host-loss recovery. Fresh eligible peers prepare wit...
Definition handoff.c:194
asciichat_error_t consensus_handoff_receive(consensus_handoff_t *state, const consensus_handoff_message_t *message, size_t length, uint64_t now_ms)
Accept a member's probe or preparation reply using receiver-clock time. Probe metadata becomes eligib...
Definition handoff.c:114
void consensus_handoff_host_lost(consensus_handoff_t *state, const uint8_t host[SESSION_ID_SIZE])
Record loss of the incumbent, ignoring delayed reports about old hosts. The caller authenticates the ...
Definition handoff.c:103
#define CONSENSUS_HANDOFF_HEADER
Definition handoff.h:15
asciichat_error_t consensus_handoff_decode(const void *data, size_t length, consensus_handoff_message_t *out)
Definition handoff.c:16
void consensus_handoff_init(consensus_handoff_t *state, const uint8_t session[SESSION_ID_SIZE], const uint8_t host[SESSION_ID_SIZE])
Definition handoff.c:51
asciichat_error_t consensus_handoff_join(consensus_handoff_t *state, const uint8_t id[SESSION_ID_SIZE])
Definition handoff.c:63
void consensus_handoff_leave(consensus_handoff_t *state, const uint8_t id[SESSION_ID_SIZE])
Definition handoff.c:77
void consensus_handoff_encode(const consensus_handoff_message_t *message, uint8_t out[64])
consensus_handoff_kind_t
Definition handoff.h:21
@ HANDOFF_REJECT
Definition handoff.h:28
@ HANDOFF_SAMPLE_DATA
Definition handoff.h:23
@ HANDOFF_COMMIT
Definition handoff.h:27
@ HANDOFF_FAILED
Definition handoff.h:29
@ HANDOFF_PLAN
Definition handoff.h:26
@ HANDOFF_SAMPLE_ACK
Definition handoff.h:30
@ HANDOFF_READY
Definition handoff.h:25
@ HANDOFF_PREPARE
Definition handoff.h:24
@ HANDOFF_SAMPLE_START
Definition handoff.h:22
⚙️ Common definitions, error codes, macros, and types shared throughout the application
deferred_action_t action
static bool size_t gotel_query_t * out
Definition queries.h:10
uint8_t session[SESSION_ID_SIZE]
Definition handoff.h:35
uint8_t participant[SESSION_ID_SIZE]
Definition handoff.h:36
consensus handoff message is intentionally a small, concrete record. Fields such as kind,...
Definition handoff.h:53
uint64_t probe_started_ms
Definition handoff.h:63
uint8_t pending_capabilities
Definition handoff.h:58
uint32_t host_sequence
Last committed round; preparation does not change host authority.
Definition handoff.h:78
uint8_t session[SESSION_ID_SIZE]
Definition handoff.h:73
uint8_t successor[SESSION_ID_SIZE]
Definition handoff.h:75
uint64_t monitoring_started_ms
Definition handoff.h:84
uint64_t prepare_deadline_ms
Definition handoff.h:79
uint32_t generation
Definition handoff.h:76
consensus_handoff_peer_t peers[MAX_SESSION_PARTICIPANTS]
Definition handoff.h:86
uint64_t failure_deadline_ms
Definition handoff.h:83
uint8_t host[SESSION_ID_SIZE]
Definition handoff.h:74