From caa79bd1a19175c71933ef3fa7dd9a7ca871cad8 Mon Sep 17 00:00:00 2001 From: Patrick Lodder Date: Thu, 20 Jun 2024 10:03:43 -0400 Subject: [PATCH] random: use std::shuffle instead of std::random_shuffle random_shuffle is deprecated since c++11 and removed in c++17. Use the shuffle function instead, now that we have a standardized interface available on FastRandomContext. This enables c++17 compilation --- src/net_processing.cpp | 3 ++- src/wallet/wallet.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 832ca33a5..f67fb9e5f 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1641,7 +1641,8 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr // Randomize entries before processing, to prevent an attacker to // determine which entries will make it through the rate limit - random_shuffle(vAddr.begin(), vAddr.end(), GetRandInt); + FastRandomContext insecure_rand; + shuffle(vAddr.begin(), vAddr.end(), insecure_rand); BOOST_FOREACH(CAddress& addr, vAddr) { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 0d59c548a..58f69aa96 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2157,6 +2157,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin { setCoinsRet.clear(); nValueRet = 0; + FastRandomContext insecure_rand; // List of values less than target pair > coinLowestLarger; @@ -2165,7 +2166,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin vector > > vValue; CAmount nTotalLower = 0; - random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt); + shuffle(vCoins.begin(), vCoins.end(), insecure_rand); BOOST_FOREACH(const COutput &output, vCoins) {