Avoid unordered_map in Raft code for more determinism

This commit is contained in:
Tyler Neely 2022-11-17 21:24:13 +00:00
parent 098084314e
commit 262df5c6a2

View File

@ -19,7 +19,6 @@
#include <map> #include <map>
#include <set> #include <set>
#include <thread> #include <thread>
#include <unordered_map>
#include <vector> #include <vector>
#include <boost/core/demangle.hpp> #include <boost/core/demangle.hpp>
@ -182,7 +181,7 @@ struct PendingClientRequest {
struct Leader { struct Leader {
std::map<Address, FollowerTracker> followers; std::map<Address, FollowerTracker> followers;
std::unordered_map<LogIndex, PendingClientRequest> pending_client_requests; std::map<LogIndex, PendingClientRequest> pending_client_requests;
Time last_broadcast = Time::min(); Time last_broadcast = Time::min();
std::string static ToString() { return "\tLeader \t"; } std::string static ToString() { return "\tLeader \t"; }
@ -683,7 +682,7 @@ class Raft {
return Leader{ return Leader{
.followers = std::move(followers), .followers = std::move(followers),
.pending_client_requests = std::unordered_map<LogIndex, PendingClientRequest>(), .pending_client_requests = std::map<LogIndex, PendingClientRequest>(),
}; };
} }