feat(raft-library): task 3.1 — raft_init validation, state init, raft_snapshot; 12 tests
This commit is contained in:
parent
d109155a21
commit
1aa7db4583
4 changed files with 368 additions and 8 deletions
|
|
@ -24,7 +24,7 @@
|
|||
- _Requirements: 1.2, 7.1, 7.2, 7.3_
|
||||
|
||||
- [ ] 3. Core state machine implementation (raft.c)
|
||||
- [ ] 3.1 Implement raft_init and raft_snapshot
|
||||
- [x] 3.1 Implement raft_init and raft_snapshot
|
||||
- `raft_init` validates all required callback pointers are non-NULL (all except `on_vote_eligible` and `on_trace`); returns `-EINVAL` without modifying state if any required callback is NULL or `n_peers < 1`
|
||||
- Initializes from `raft_config_t`: copies `n_peers`, `self_idx`, `election_timeout_ms` (apply 2000ms default if 0), `my_priority`, `initial_term`, `initial_voted_for`; sets `role=FOLLOWER`, `votes_granted=0`, `replies_received=0`, `election_decided=0`
|
||||
- `raft_snapshot()` fills snap with current field values (called while caller holds lock)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue