From 1824c12975bc83668fdb2626885aedd4a69d8911 Mon Sep 17 00:00:00 2001 From: Kamil Braun Date: Mon, 15 Jan 2024 15:54:48 +0100 Subject: [PATCH] raft: remove `empty()` from `fsm_output` Nobody remembered to keep this function up to date when adding stuff to `fsm_output`. Turns out that it's not being used by any Raft logic but only in some tests. That use case can now be replaced with `fsm::has_output()` which is also being used by `raft::server` code. --- raft/fsm.hh | 8 -------- test/raft/helpers.cc | 3 ++- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/raft/fsm.hh b/raft/fsm.hh index 964e1a6765..24e52589c7 100644 --- a/raft/fsm.hh +++ b/raft/fsm.hh @@ -46,14 +46,6 @@ struct fsm_output { bool state_changed = false; // Set to true if a leadership transfer was aborted since the last output bool abort_leadership_transfer; - - // True if there is no new output - bool empty() const { - return !term_and_vote && - log_entries.size() == 0 && messages.size() == 0 && - committed.size() == 0 && !snp && snps_to_drop.empty() && - !configuration && !max_read_id_with_quorum; - } }; struct fsm_config { diff --git a/test/raft/helpers.cc b/test/raft/helpers.cc index 551879b198..06a68ee6db 100644 --- a/test/raft/helpers.cc +++ b/test/raft/helpers.cc @@ -94,7 +94,8 @@ communicate_impl(std::function stop_pred, raft_routing_map& map) { has_traffic = false; for (auto e : map) { raft::fsm& from = *e.second; - for (auto output = from.get_output(); !output.empty(); output = from.get_output()) { + for (bool has_output = from.has_output(); has_output; has_output = from.has_output()) { + auto output = from.get_output(); if (stop_pred()) { return; }