Skip to content

Commit

Permalink
Removes the boost/algorithm/string/join dependency
Browse files Browse the repository at this point in the history
This commit removes the `boost/algorithm/string/join` dependency
from the project by replacing `boost::algorithm::join` with
a simple helper function.

Cherry-picked from: 5f019d5
  • Loading branch information
l2a5b1 authored and xanimo committed Mar 29, 2024
1 parent b00d1de commit 3155a5d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
#endif

#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()
#include <boost/interprocess/sync/file_lock.hpp>
#include <boost/thread.hpp>
Expand Down
25 changes: 16 additions & 9 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#include <sstream>

#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/bind/bind.hpp>
#include <boost/math/distributions/poisson.hpp>
#include <boost/thread.hpp>
Expand Down Expand Up @@ -2172,34 +2171,42 @@ void PruneAndFlush() {
FlushStateToDisk(state, FLUSH_STATE_NONE);
}

/** Update chainActive and related internal data structures. */
void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
chainActive.SetTip(pindexNew);
/** Private helper function that concatenates warning messages. */
static void AppendWarning(std::string& res, const std::string& warn)
{
if (!res.empty()) res += ", ";
res += warn;
}

/** Check warning conditions and do some notifications on new chain tip set. */
void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainParams) {
chainActive.SetTip((CBlockIndex *)pindexNew);

// New best block
mempool.AddTransactionsUpdated(1);

cvBlockChange.notify_all();

static bool fWarned = false;
std::vector<std::string> warningMessages;
std::string warningMessages;
if (!IsInitialBlockDownload())
{
int nUpgraded = 0;
const CBlockIndex* pindex = chainActive.Tip();
for (int bit = 0; bit < VERSIONBITS_NUM_BITS; bit++) {
WarningBitsConditionChecker checker(bit);
ThresholdState state = checker.GetStateFor(pindex, chainParams.GetConsensus(pindex->nHeight), warningcache[bit]);
std::string strWarning;
if (state == THRESHOLD_ACTIVE || state == THRESHOLD_LOCKED_IN) {
if (state == THRESHOLD_ACTIVE) {
std::string strWarning = strprintf(_("Warning: unknown new rules activated (versionbit %i)"), bit);
strWarning = strprintf(_("Warning: unknown new rules activated (versionbit %i)"), bit);
SetMiscWarning(strWarning);
if (!fWarned) {
AlertNotify(strWarning);
fWarned = true;
}
} else {
warningMessages.push_back(strprintf("unknown new rules are about to activate (versionbit %i)", bit));
AppendWarning(warningMessages, strWarning);
}
}
}
Expand All @@ -2212,7 +2219,7 @@ void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
pindex = pindex->pprev;
}
if (nUpgraded > 0)
warningMessages.push_back(strprintf("%d of last 100 blocks have unexpected version", nUpgraded));
AppendWarning(warningMessages, strprintf(_("%d of last 100 blocks have unexpected version"), nUpgraded));
if (nUpgraded > 100/2)
{
std::string strWarning = _("Warning: Unknown block versions being mined! It's possible unknown rules are in effect");
Expand All @@ -2230,7 +2237,7 @@ void static UpdateTip(CBlockIndex *pindexNew, const CChainParams& chainParams) {
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
GuessVerificationProgress(chainParams.TxData(), chainActive.Tip()), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize());
if (!warningMessages.empty())
LogPrintf(" warning='%s'", boost::algorithm::join(warningMessages, ", "));
LogPrintf(" warning='%s'", warningMessages); /* Continued */
LogPrintf("\n");

}
Expand Down

0 comments on commit 3155a5d

Please sign in to comment.