diff --git a/include/opendht/dht.h b/include/opendht/dht.h index e060139e681d58303a3198187349f9f03cd68e9a..98ecd7e571a52f43abaed3bdb05efb7b133f3882 100644 --- a/include/opendht/dht.h +++ b/include/opendht/dht.h @@ -211,42 +211,42 @@ private: /* When performing a search, we search for up to SEARCH_NODES closest nodes to the destination, and use the additional ones to backtrack if any of the target 8 turn out to be dead. */ - static const unsigned SEARCH_NODES {14}; + static constexpr unsigned SEARCH_NODES {14}; /* The maximum number of values we store for a given hash. */ - static const unsigned MAX_VALUES {2048}; + static constexpr unsigned MAX_VALUES {2048}; /* The maximum number of hashes we're willing to track. */ - static const unsigned MAX_HASHES {16384}; + static constexpr unsigned MAX_HASHES {16384}; /* The maximum number of searches we keep data about. */ - static const unsigned MAX_SEARCHES {1024}; + static constexpr unsigned MAX_SEARCHES {1024}; /* Time for a request to timeout */ - static const time_t MAX_RESPONSE_TIME {6}; + static constexpr time_t MAX_RESPONSE_TIME {6}; /* A search with no nodes will timeout after this time. */ - static const time_t SEARCH_TIMEOUT {6}; + static constexpr time_t SEARCH_TIMEOUT {6}; /* The time after which we can send get requests for a search in case of no answers. */ - static const time_t SEARCH_GET_STEP {6}; + static constexpr time_t SEARCH_GET_STEP {6}; /* The time after which we consider a search to be expirable. */ - static const time_t SEARCH_EXPIRE_TIME {62 * 60}; + static constexpr time_t SEARCH_EXPIRE_TIME {62 * 60}; /* The time after which we consider a node to be expirable. */ - static const time_t NODE_EXPIRE_TIME {15 * 60}; + static constexpr time_t NODE_EXPIRE_TIME {15 * 60}; /* The maximum number of nodes that we snub. There is probably little reason to increase this value. */ - static const unsigned BLACKLISTED_MAX {10}; + static constexpr unsigned BLACKLISTED_MAX {10}; - static const long unsigned MAX_REQUESTS_PER_SEC; + static constexpr long unsigned MAX_REQUESTS_PER_SEC {400}; - static const time_t TOKEN_EXPIRE_TIME {10 * 60}; + static constexpr time_t TOKEN_EXPIRE_TIME {10 * 60}; - static const unsigned TOKEN_SIZE {64}; + static constexpr unsigned TOKEN_SIZE {64}; struct Node { InfoHash id {}; diff --git a/src/dht.cpp b/src/dht.cpp index 9625b754e739c5656baae17855672e07c006ae32..3a427e475d405402408244ff91c1926c6d6b4542 100644 --- a/src/dht.cpp +++ b/src/dht.cpp @@ -117,7 +117,7 @@ static constexpr InfoHash ones = {std::array<uint8_t, HASH_LEN>{ 0xFF, 0xFF, 0xFF, 0xFF }}; -const long unsigned Dht::MAX_REQUESTS_PER_SEC = 400; +constexpr long unsigned Dht::MAX_REQUESTS_PER_SEC; void Dht::setLoggers(LogMethod&& error, LogMethod&& warn, LogMethod&& debug)