mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-02 08:55:53 +00:00
Replace boost::clamp with std::clamp
This commit is contained in:
committed by
Nik Bougalis
parent
cf70ecbd6d
commit
9f75f2d522
@@ -28,7 +28,6 @@
|
|||||||
#include <ripple/json/json_reader.h>
|
#include <ripple/json/json_reader.h>
|
||||||
#include <ripple/protocol/PublicKey.h>
|
#include <ripple/protocol/PublicKey.h>
|
||||||
#include <ripple/protocol/Sign.h>
|
#include <ripple/protocol/Sign.h>
|
||||||
#include <boost/algorithm/clamp.hpp>
|
|
||||||
#include <boost/algorithm/string/trim.hpp>
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
#include <ripple/protocol/Feature.h>
|
#include <ripple/protocol/Feature.h>
|
||||||
#include <ripple/protocol/jss.h>
|
#include <ripple/protocol/jss.h>
|
||||||
#include <ripple/protocol/st.h>
|
#include <ripple/protocol/st.h>
|
||||||
#include <boost/algorithm/clamp.hpp>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
@@ -111,11 +110,11 @@ TxQ::FeeMetrics::update(
|
|||||||
// Ledgers are taking to long to process,
|
// Ledgers are taking to long to process,
|
||||||
// so clamp down on limits.
|
// so clamp down on limits.
|
||||||
auto const cutPct = 100 - setup.slowConsensusDecreasePercent;
|
auto const cutPct = 100 - setup.slowConsensusDecreasePercent;
|
||||||
// upperLimit must be >= minimumTxnCount_ or boost::clamp can give
|
// upperLimit must be >= minimumTxnCount_ or std::clamp can give
|
||||||
// unexpected results
|
// unexpected results
|
||||||
auto const upperLimit = std::max<std::uint64_t>(
|
auto const upperLimit = std::max<std::uint64_t>(
|
||||||
mulDiv(txnsExpected_, cutPct, 100).second, minimumTxnCount_);
|
mulDiv(txnsExpected_, cutPct, 100).second, minimumTxnCount_);
|
||||||
txnsExpected_ = boost::algorithm::clamp(
|
txnsExpected_ = std::clamp<std::uint64_t>(
|
||||||
mulDiv(size, cutPct, 100).second, minimumTxnCount_, upperLimit);
|
mulDiv(size, cutPct, 100).second, minimumTxnCount_, upperLimit);
|
||||||
recentTxnCounts_.clear();
|
recentTxnCounts_.clear();
|
||||||
}
|
}
|
||||||
@@ -1885,7 +1884,7 @@ setup_TxQ(Config const& config)
|
|||||||
"normal_consensus_increase_percent",
|
"normal_consensus_increase_percent",
|
||||||
section);
|
section);
|
||||||
setup.normalConsensusIncreasePercent =
|
setup.normalConsensusIncreasePercent =
|
||||||
boost::algorithm::clamp(setup.normalConsensusIncreasePercent, 0, 1000);
|
std::clamp(setup.normalConsensusIncreasePercent, 0u, 1000u);
|
||||||
|
|
||||||
/* If this percentage is outside of the 0-100 range, the results
|
/* If this percentage is outside of the 0-100 range, the results
|
||||||
are nonsensical (uint overflows happen, so the limit grows
|
are nonsensical (uint overflows happen, so the limit grows
|
||||||
@@ -1895,7 +1894,7 @@ setup_TxQ(Config const& config)
|
|||||||
"slow_consensus_decrease_percent",
|
"slow_consensus_decrease_percent",
|
||||||
section);
|
section);
|
||||||
setup.slowConsensusDecreasePercent =
|
setup.slowConsensusDecreasePercent =
|
||||||
boost::algorithm::clamp(setup.slowConsensusDecreasePercent, 0, 100);
|
std::clamp(setup.slowConsensusDecreasePercent, 0u, 100u);
|
||||||
|
|
||||||
set(setup.maximumTxnPerAccount, "maximum_txn_per_account", section);
|
set(setup.maximumTxnPerAccount, "maximum_txn_per_account", section);
|
||||||
set(setup.minimumLastLedgerBuffer, "minimum_last_ledger_buffer", section);
|
set(setup.minimumLastLedgerBuffer, "minimum_last_ledger_buffer", section);
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
#include <ripple/json/json_reader.h>
|
#include <ripple/json/json_reader.h>
|
||||||
#include <ripple/protocol/digest.h>
|
#include <ripple/protocol/digest.h>
|
||||||
#include <ripple/protocol/jss.h>
|
#include <ripple/protocol/jss.h>
|
||||||
#include <boost/algorithm/clamp.hpp>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
@@ -469,10 +468,10 @@ ValidatorSite::parseJsonResponse(
|
|||||||
body[jss::refresh_interval].isNumeric())
|
body[jss::refresh_interval].isNumeric())
|
||||||
{
|
{
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
std::chrono::minutes const refresh = boost::algorithm::clamp(
|
std::chrono::minutes const refresh = std::clamp(
|
||||||
std::chrono::minutes{body[jss::refresh_interval].asUInt()},
|
std::chrono::minutes{body[jss::refresh_interval].asUInt()},
|
||||||
1min,
|
1min,
|
||||||
24h);
|
std::chrono::minutes{24h});
|
||||||
sites_[siteIdx].refreshInterval = refresh;
|
sites_[siteIdx].refreshInterval = refresh;
|
||||||
sites_[siteIdx].nextRefresh =
|
sites_[siteIdx].nextRefresh =
|
||||||
clock_type::now() + sites_[siteIdx].refreshInterval;
|
clock_type::now() + sites_[siteIdx].refreshInterval;
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include <ripple/protocol/UintTypes.h>
|
#include <ripple/protocol/UintTypes.h>
|
||||||
|
|
||||||
#include <ripple/rpc/impl/Tuning.h>
|
#include <ripple/rpc/impl/Tuning.h>
|
||||||
#include <boost/algorithm/clamp.hpp>
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@@ -624,8 +623,7 @@ PathRequest::findPaths(
|
|||||||
after four source currencies, 50 - (4 * 4) = 34.
|
after four source currencies, 50 - (4 * 4) = 34.
|
||||||
*/
|
*/
|
||||||
int const size = sourceCurrencies.size();
|
int const size = sourceCurrencies.size();
|
||||||
consumer_.charge(
|
consumer_.charge({std::clamp(size * size + 34, 50, 400), "path update"});
|
||||||
{boost::algorithm::clamp(size * size + 34, 50, 400), "path update"});
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,6 @@
|
|||||||
#include <ripple/protocol/SecretKey.h>
|
#include <ripple/protocol/SecretKey.h>
|
||||||
#include <ripple/protocol/digest.h>
|
#include <ripple/protocol/digest.h>
|
||||||
|
|
||||||
#include <boost/algorithm/clamp.hpp>
|
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
namespace NodeStore {
|
namespace NodeStore {
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,6 @@
|
|||||||
#include <ripple/overlay/predicates.h>
|
#include <ripple/overlay/predicates.h>
|
||||||
#include <ripple/protocol/digest.h>
|
#include <ripple/protocol/digest.h>
|
||||||
|
|
||||||
#include <boost/algorithm/clamp.hpp>
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
#include <boost/beast/core/ostream.hpp>
|
#include <boost/beast/core/ostream.hpp>
|
||||||
@@ -1910,7 +1909,7 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMProposeSet> const& m)
|
|||||||
|
|
||||||
// Preliminary check for the validity of the signature: A DER encoded
|
// Preliminary check for the validity of the signature: A DER encoded
|
||||||
// signature can't be longer than 72 bytes.
|
// signature can't be longer than 72 bytes.
|
||||||
if ((boost::algorithm::clamp(sig.size(), 64, 72) != sig.size()) ||
|
if ((std::clamp<std::size_t>(sig.size(), 64, 72) != sig.size()) ||
|
||||||
(publicKeyType(makeSlice(set.nodepubkey())) != KeyType::secp256k1))
|
(publicKeyType(makeSlice(set.nodepubkey())) != KeyType::secp256k1))
|
||||||
{
|
{
|
||||||
JLOG(p_journal_.warn()) << "Proposal: malformed";
|
JLOG(p_journal_.warn()) << "Proposal: malformed";
|
||||||
|
|||||||
Reference in New Issue
Block a user