Make Address's == and < operators consider uuid

This commit is contained in:
Tyler Neely 2022-07-28 16:06:48 +00:00
parent 51371398ce
commit 9056e2c97a

View File

@ -36,14 +36,20 @@ struct Address {
}
bool operator==(const Address &other) const {
return (last_known_ip == other.last_known_ip) && (last_known_port == other.last_known_port);
return ((unique_id == other.unique_id) && last_known_ip == other.last_known_ip) &&
(last_known_port == other.last_known_port);
}
/// unique_id is most dominant for ordering, then last_known_ip, then last_known_port
bool operator<(const Address &other) const {
if (last_known_ip == other.last_known_ip) {
return last_known_port < other.last_known_port;
if (unique_id == other.unique_id) {
if (last_known_ip == other.last_known_ip) {
return last_known_port < other.last_known_port;
} else {
return last_known_ip < other.last_known_ip;
}
} else {
return last_known_ip < other.last_known_ip;
return unique_id < other.unique_id;
}
}
};