ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
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/* Versioned control frames. Integer fields are explicitly encoded, never cast
8 * from transport buffers. All deadlines belong to the receiver's clock. */
9#define CONSENSUS_HANDOFF_PACKET 6090
10#define CONSENSUS_HANDOFF_VERSION 1
11#define CONSENSUS_HANDOFF_HEADER 64
12#define CONSENSUS_HANDOFF_PROBE_BYTES 65536
13#define CONSENSUS_HANDOFF_FRESH_MS 15000
14#define CONSENSUS_HANDOFF_PREPARE_MS 5000
15#define CONSENSUS_HANDOFF_RECOVERY_MS 15000
16
28
43
65
87
91 const uint8_t host[SESSION_ID_SIZE]);
94/* Caller authenticates participant/session against the transport identity. */
96 size_t length, uint64_t now_ms);
97/* Returns one action, or false when the state is unchanged. */
99
100/* Caller authenticates the reporter; obsolete host reports are ignored. */
deferred_action_t action
Definition actions.c:77
⚙️ Common definitions, error codes, macros, and types shared throughout the application
Deterministic host election algorithm.
unsigned short uint16_t
Definition common.h:61
unsigned int uint32_t
Definition common.h:62
unsigned long long uint64_t
Definition common.h:63
unsigned char uint8_t
Definition common.h:60
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:44
#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:207
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:116
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:105
#define CONSENSUS_HANDOFF_HEADER
Definition handoff.h:11
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:52
asciichat_error_t consensus_handoff_join(consensus_handoff_t *state, const uint8_t id[SESSION_ID_SIZE])
Definition handoff.c:65
void consensus_handoff_leave(consensus_handoff_t *state, const uint8_t id[SESSION_ID_SIZE])
Definition handoff.c:79
void consensus_handoff_encode(const consensus_handoff_message_t *message, uint8_t out[64])
consensus_handoff_kind_t
Definition handoff.h:17
@ HANDOFF_REJECT
Definition handoff.h:24
@ HANDOFF_SAMPLE_DATA
Definition handoff.h:19
@ HANDOFF_COMMIT
Definition handoff.h:23
@ HANDOFF_FAILED
Definition handoff.h:25
@ HANDOFF_PLAN
Definition handoff.h:22
@ HANDOFF_SAMPLE_ACK
Definition handoff.h:26
@ HANDOFF_READY
Definition handoff.h:21
@ HANDOFF_PREPARE
Definition handoff.h:20
@ HANDOFF_SAMPLE_START
Definition handoff.h:18
static bool size_t gotel_query_t * out
Definition queries.h:8
uint8_t session[SESSION_ID_SIZE]
Definition handoff.h:31
uint8_t participant[SESSION_ID_SIZE]
Definition handoff.h:32
consensus handoff message is intentionally a small, concrete record. Fields such as kind,...
Definition handoff.h:47
uint64_t probe_started_ms
Definition handoff.h:57
uint8_t pending_capabilities
Definition handoff.h:52
uint32_t host_sequence
Last committed round; preparation does not change host authority.
Definition handoff.h:72
uint8_t session[SESSION_ID_SIZE]
Definition handoff.h:67
uint8_t successor[SESSION_ID_SIZE]
Definition handoff.h:69
uint64_t monitoring_started_ms
Definition handoff.h:78
uint64_t prepare_deadline_ms
Definition handoff.h:73
uint32_t generation
Definition handoff.h:70
consensus_handoff_peer_t peers[MAX_SESSION_PARTICIPANTS]
Definition handoff.h:80
uint64_t failure_deadline_ms
Definition handoff.h:77
uint8_t host[SESSION_ID_SIZE]
Definition handoff.h:68