Skip to content

Commit

Permalink
Simplify node process
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanc-n committed Sep 21, 2024
1 parent 63beb4b commit e69d0ba
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/cluster/cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -773,13 +773,11 @@ Status Cluster::parseClusterNodes(const std::string &nodes_str, ClusterNodes *no

// 6) slot info
auto valid_range = NumericRange<int>{0, kClusterSlots - 1};
const std::regex node_id_regex(R"(\b[a-fA-F0-9]{40}\b)");
for (unsigned i = 5; i < fields.size(); i++) {
std::vector<std::string> ranges = util::Split(fields[i], "-");
if (ranges.size() == 1) {
std::regex node_id_regex(R"(\b[a-fA-F0-9]{40}\b)");
auto matches = std::sregex_iterator(nodes_info[0].begin(), nodes_info[0].end(), node_id_regex);

if (std::distance(matches, std::sregex_iterator()) > 1 || nodes_info[0].find(' ') == std::string::npos) {
if (std::regex_match(fields[i], node_id_regex)) {
return {Status::ClusterInvalidInfo, "Invalid nodes definition: Missing newline between node entries."};
}

Expand Down

0 comments on commit e69d0ba

Please sign in to comment.