diff --git a/include/opendht/log_enable.h b/include/opendht/log_enable.h index b55f5556..7310de54 100644 --- a/include/opendht/log_enable.h +++ b/include/opendht/log_enable.h @@ -75,7 +75,7 @@ struct Logger { LogMethod ERR = NOLOG; void setFilter(const InfoHash& f) { filter_ = f; - filterEnable_ = filter_ != InfoHash{}; + filterEnable_ = static_cast(filter_); } inline void log0(const LogMethod& logger, char const* format, va_list args) const { #if OPENDHT_LOG diff --git a/tools/dhtchat.cpp b/tools/dhtchat.cpp index 8e48723f..3bd89f1c 100644 --- a/tools/dhtchat.cpp +++ b/tools/dhtchat.cpp @@ -88,8 +88,6 @@ main(int argc, char **argv) if (line.empty()) continue; - static constexpr dht::InfoHash INVALID_ID {}; - std::istringstream iss(line); std::string op, idstr; iss >> op; @@ -99,7 +97,7 @@ main(int argc, char **argv) else if (op == "c") { iss >> idstr; room = InfoHash(idstr); - if (room == INVALID_ID) { + if (not room) { room = InfoHash::get(idstr); std::cout << "Joining h(" << idstr << ") = " << room << std::endl; } diff --git a/tools/dhtnode.cpp b/tools/dhtnode.cpp index 96cb394d..a55d3d20 100644 --- a/tools/dhtnode.cpp +++ b/tools/dhtnode.cpp @@ -116,20 +116,18 @@ void cmd_loop(std::shared_ptr& dht, dht_params& params) } else if (op == "ld") { iss >> idstr; InfoHash filter(idstr); - if (filter == InfoHash{}) - std::cout << dht->getStorageLog() << std::endl; - else + if (filter) std::cout << dht->getStorageLog(filter) << std::endl; + else + std::cout << dht->getStorageLog() << std::endl; continue; } else if (op == "ls") { iss >> idstr; InfoHash filter(idstr); - if (filter == InfoHash{}) { - std::cout << "Searches:" << std::endl; - std::cout << dht->getSearchesLog() << std::endl; - } else { + if (filter) std::cout << dht->getSearchLog(filter) << std::endl; - } + else + std::cout << dht->getSearchesLog() << std::endl; continue; } else if (op == "la") { std::cout << "Reported public addresses:" << std::endl; diff --git a/tools/tools_common.h b/tools/tools_common.h index 933cc7e2..2e4d72b0 100644 --- a/tools/tools_common.h +++ b/tools/tools_common.h @@ -98,10 +98,8 @@ dht::indexation::Pht::Key createPhtKey(std::map pht_ke return pht_key; } -bool isInfoHash(dht::InfoHash& h) { - static constexpr dht::InfoHash INVALID_ID {}; - - if (h == INVALID_ID) { +bool isInfoHash(const dht::InfoHash& h) { + if (not h) { std::cout << "Syntax error: invalid InfoHash." << std::endl; return false; }