Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/dash/lint-tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ iwyu_tool.py \
"src/util/moneystr.cpp" \
"src/util/serfloat.cpp" \
"src/util/spanparsing.cpp" \
"src/util/string.cpp" \
"src/util/strencodings.cpp" \
"src/util/syserror.cpp" \
"src/util/url.cpp" \
Expand Down
12 changes: 12 additions & 0 deletions src/.clang-tidy
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
Checks: '
-*,
bugprone-argument-comment,
bugprone-use-after-move,
misc-unused-using-decls,
modernize-use-default-member-init,
modernize-use-nullptr,
performance-for-range-copy,
performance-move-const-arg,
performance-unnecessary-copy-initialization,
readability-const-return-type,
readability-redundant-declaration,
readability-redundant-string-init,
'
WarningsAsErrors: '
bugprone-argument-comment,
bugprone-use-after-move,
misc-unused-using-decls,
modernize-use-default-member-init,
modernize-use-nullptr,
performance-move-const-arg,
performance-unnecessary-copy-initialization,
readability-redundant-declaration,
readability-redundant-string-init,
'
CheckOptions:
- key: performance-move-const-arg.CheckTriviallyCopyableMove
value: false
2 changes: 1 addition & 1 deletion src/bench/load_external.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static void LoadExternalBlockFile(benchmark::Bench& bench)
// block data) as a stream object.
const fs::path blkfile{testing_setup.get()->m_path_root / "blk.dat"};
CDataStream ss(SER_DISK, 0);
auto params{Params()};
const auto& params{Params()};
ss << params.MessageStart();
ss << static_cast<uint32_t>(benchmark::data::block813851.size());
// We can't use the streaming serialization (ss << benchmark::data::block813851)
Expand Down
2 changes: 0 additions & 2 deletions src/bench/wallet_loading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
using wallet::CWallet;
using wallet::DatabaseFormat;
using wallet::DatabaseOptions;
using wallet::ISMINE_SPENDABLE;
using wallet::MakeWalletDatabase;
using wallet::TxStateInactive;
using wallet::WALLET_FLAG_DESCRIPTORS;
using wallet::WalletContext;
Expand Down
2 changes: 1 addition & 1 deletion src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ static void GetWalletBalances(UniValue& result)

UniValue balances(UniValue::VOBJ);
for (const UniValue& wallet : wallets.getValues()) {
const std::string wallet_name = wallet.get_str();
const std::string& wallet_name = wallet.get_str();
const UniValue getbalances = ConnectAndCallRPC(&rh, "getbalances", /* args=*/{}, wallet_name);
const UniValue& balance = getbalances.find_value("result")["mine"]["trusted"];
balances.pushKV(wallet_name, balance);
Expand Down
2 changes: 1 addition & 1 deletion src/bitcoin-tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr)
UniValue prevtxsObj = registers["prevtxs"];
{
for (unsigned int previdx = 0; previdx < prevtxsObj.size(); previdx++) {
UniValue prevOut = prevtxsObj[previdx];
const UniValue& prevOut = prevtxsObj[previdx];
if (!prevOut.isObject())
throw std::runtime_error("expected prevtxs internal object");

Expand Down
2 changes: 1 addition & 1 deletion src/blockfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const std::set<BlockFilterType>& AllBlockFilterTypes()

static std::once_flag flag;
std::call_once(flag, []() {
for (auto entry : g_filter_types) {
for (const auto& entry : g_filter_types) {
types.insert(entry.first);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/bls/bls_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ template <typename T>
bool VerifyVectorHelper(Span<T> vec)
{
std::set<uint256> set;
for (auto item : vec) {
for (const auto& item : vec) {
if (!item.IsValid())
return false;
// check duplicates
Expand Down
2 changes: 1 addition & 1 deletion src/coins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ bool CCoinsViewErrorCatcher::GetCoin(const COutPoint &outpoint, Coin &coin) cons
try {
return CCoinsViewBacked::GetCoin(outpoint, coin);
} catch(const std::runtime_error& e) {
for (auto f : m_err_callbacks) {
for (const auto& f : m_err_callbacks) {
f();
}
LogPrintf("Error reading from database: %s\n", e.what());
Expand Down
2 changes: 1 addition & 1 deletion src/core_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ int ParseSighashString(const UniValue& sighash)
{std::string("SINGLE"), int(SIGHASH_SINGLE)},
{std::string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY)},
};
std::string strHashType = sighash.get_str();
const std::string& strHashType = sighash.get_str();
const auto& it = map_sighash_values.find(strHashType);
if (it != map_sighash_values.end()) {
hash_type = it->second;
Expand Down
2 changes: 1 addition & 1 deletion src/evo/creditpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static std::optional<CreditPoolDataPerBlock> GetCreditDataFromBlock(const gsl::n
LogPrintf("%s: WARNING: No valid CbTx at height=%d\n", __func__, block_index->nHeight);
return std::nullopt;
}
for (CTransactionRef tx : block.vtx) {
for (const CTransactionRef& tx : block.vtx) {
if (!tx->IsSpecialTxVersion() || tx->nType != TRANSACTION_ASSET_UNLOCK) continue;

CAmount unlocked{0};
Expand Down
4 changes: 1 addition & 3 deletions src/evo/mnauth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternode
if (Params().NetworkIDString() != CBaseChainParams::MAIN && gArgs.IsArgSet("-pushversion")) {
nOurNodeVersion = gArgs.GetIntArg("-pushversion", PROTOCOL_VERSION);
}
auto pk = mn_activeman.GetPubKey();
const CBLSPublicKey pubKey(pk);
const uint256 signHash{::SerializeHash(std::make_tuple(pubKey, receivedMNAuthChallenge, peer.IsInboundConn(), nOurNodeVersion))};
const uint256 signHash{::SerializeHash(std::make_tuple(mn_activeman.GetPubKey(), receivedMNAuthChallenge, peer.IsInboundConn(), nOurNodeVersion))};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix persistent clang-format violations.

The pipeline continues to report formatting differences in this file. Although a previous comment indicated this was addressed, the current pipeline failure shows clang-format compliance is still required.

Run the following command to verify and fix formatting:

#!/bin/bash
# Show the formatting differences detected by clang-format
clang-format src/evo/mnauth.cpp | diff -u src/evo/mnauth.cpp - || echo "Formatting differences detected"
🤖 Prompt for AI Agents
In src/evo/mnauth.cpp around line 39, the expression constructing signHash is
violating clang-format rules; run clang-format on this file (or the repo) and
apply the formatting changes so the line matches the project's clang-format
style (e.g., wrap/align long tuple arguments or split into multiple lines as
clang-format dictates), then re-run the provided diff command to confirm no
formatting differences remain and commit the modified file.


mnauth.proRegTxHash = mn_activeman.GetProTxHash();

Expand Down
2 changes: 1 addition & 1 deletion src/evo/specialtxman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ bool CSpecialTxProcessor::RebuildListFromBlock(const CBlock& block, gsl::not_nul
newList.UpdateMN(dmn.proTxHash, newState);
});

mnListRet = std::move(newList);
mnListRet = newList;

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)
static bool LockDataDirectory(bool probeOnly)
{
// Make sure only a single Dash Core process is using the data directory.
fs::path datadir = gArgs.GetDataDirNet();
const fs::path& datadir = gArgs.GetDataDirNet();
if (!DirIsWritable(datadir)) {
return InitError(strprintf(_("Cannot write to data directory '%s'; check permissions."), fs::PathToString(datadir)));
}
Expand Down
2 changes: 1 addition & 1 deletion src/instantsend/instantsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ instantsend::PendingState CInstantSendManager::FetchPendingLocks()
std::vector<uint256> removed;
removed.reserve(std::min(maxCount, pendingInstantSendLocks.size()));

for (const auto& [islockHash, nodeid_islptr_pair] : pendingInstantSendLocks) {
for (auto& [islockHash, nodeid_islptr_pair] : pendingInstantSendLocks) {
// Check if we've reached max count
if (ret.m_pending_is.size() >= maxCount) {
ret.m_pending_work = true;
Expand Down
2 changes: 1 addition & 1 deletion src/llmq/blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ bool CQuorumBlockProcessor::GetCommitmentsFromBlock(const CBlock& block, gsl::no

for (const auto& tx : block.vtx) {
if (tx->nType == TRANSACTION_QUORUM_COMMITMENT) {
const auto opt_qc = GetTxPayload<CFinalCommitmentTxPayload>(*tx);
auto opt_qc = GetTxPayload<CFinalCommitmentTxPayload>(*tx);
if (!opt_qc) {
// should not happen as it was verified before processing the block
LogPrint(BCLog::LLMQ, "CQuorumBlockProcessor::%s height=%d GetTxPayload fails\n", __func__, pindex->nHeight);
Expand Down
5 changes: 2 additions & 3 deletions src/llmq/snapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,16 @@ bool BuildQuorumRotationInfo(CDeterministicMNManager& dmnman, CQuorumSnapshotMan
response.quorumSnapshotAtHMinus4C = std::move(snapshotHMinus4C.value());
}

CSimplifiedMNListDiff mn4c;
if (!BuildSimplifiedMNListDiff(dmnman, chainman, qblockman, qman,
GetLastBaseBlockHash(baseBlockIndexes, pWorkBlockHMinus4CIndex,
use_legacy_construction),
pWorkBlockHMinus4CIndex->GetBlockHash(), mn4c, errorRet)) {
pWorkBlockHMinus4CIndex->GetBlockHash(), response.mnListDiffAtHMinus4C, errorRet)) {
response.mnListDiffAtHMinus4C = {};
return false;
}
if (!use_legacy_construction) {
baseBlockIndexes.push_back(pWorkBlockHMinus4CIndex);
}
response.mnListDiffAtHMinus4C = std::move(mn4c);
} else {
response.extraShare = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ void BCLog::Logger::LogPrintStr(const std::string& str, const std::string& loggi
}

if (m_log_threadnames && m_started_new_line) {
const auto threadname = util::ThreadGetInternalName();
const auto& threadname = util::ThreadGetInternalName();
// 16 chars total, "dash-" is 5 of them and another 1 is a NUL terminator
str_prefixed.insert(0, "[" + strprintf("%10s", (threadname.empty() ? "unknown" : threadname)) + "] ");
}
Expand Down
2 changes: 1 addition & 1 deletion src/masternode/meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ std::optional<PlatformBanMessage> CMasternodeMetaMan::GetPlatformBan(const uint2
void CMasternodeMetaMan::RememberPlatformBan(const uint256& inv_hash, PlatformBanMessage&& msg)
{
LOCK(cs);
m_seen_platform_bans.insert(inv_hash, std::move(msg));
m_seen_platform_bans.emplace(inv_hash, std::move(msg));
}

void CMasternodeMetaMan::AddUsedMasternode(const uint256& proTxHash)
Expand Down
6 changes: 3 additions & 3 deletions src/netbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
return error("Error sending to proxy");
}
uint8_t pchRet1[2];
if ((recvr = InterruptibleRecv(pchRet1, 2, g_socks5_recv_timeout, sock)) != IntrRecvError::OK) {
if (InterruptibleRecv(pchRet1, 2, g_socks5_recv_timeout, sock) != IntrRecvError::OK) {
LogPrintf("Socks5() connect to %s:%d failed: InterruptibleRecv() timeout or other failure\n", strDest, port);
return false;
}
Expand All @@ -413,7 +413,7 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
}
LogPrint(BCLog::PROXY, "SOCKS5 sending proxy authentication %s:%s\n", auth->username, auth->password);
uint8_t pchRetA[2];
if ((recvr = InterruptibleRecv(pchRetA, 2, g_socks5_recv_timeout, sock)) != IntrRecvError::OK) {
if (InterruptibleRecv(pchRetA, 2, g_socks5_recv_timeout, sock) != IntrRecvError::OK) {
return error("Error reading proxy authentication response");
}
if (pchRetA[0] != 0x01 || pchRetA[1] != 0x00) {
Expand Down Expand Up @@ -479,7 +479,7 @@ bool Socks5(const std::string& strDest, uint16_t port, const ProxyCredentials* a
if (recvr != IntrRecvError::OK) {
return error("Error reading from proxy");
}
if ((recvr = InterruptibleRecv(pchRet3, 2, g_socks5_recv_timeout, sock)) != IntrRecvError::OK) {
if (InterruptibleRecv(pchRet3, 2, g_socks5_recv_timeout, sock) != IntrRecvError::OK) {
return error("Error reading from proxy");
}
LogPrint(BCLog::NET, "SOCKS5 connected %s\n", strDest);
Expand Down
2 changes: 1 addition & 1 deletion src/node/blockstorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ void CleanupBlockRevFiles()
// Remove the rev files immediately and insert the blk file paths into an
// ordered map keyed by block file index.
LogPrintf("Removing unusable blk?????.dat and rev?????.dat files for -reindex with -prune\n");
fs::path blocksdir = gArgs.GetBlocksDirPath();
const fs::path& blocksdir = gArgs.GetBlocksDirPath();
for (fs::directory_iterator it(blocksdir); it != fs::directory_iterator(); it++) {
const std::string path = fs::PathToString(it->path().filename());
if (fs::is_regular_file(*it) &&
Expand Down
10 changes: 5 additions & 5 deletions src/qt/governancelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ Proposal::Proposal(ClientModel* _clientModel, const CGovernanceObject& _govObj,
{
UniValue prop_data;
if (prop_data.read(govObj.GetDataAsPlainString())) {
if (UniValue titleValue = prop_data.find_value("name"); titleValue.isStr()) {
if (const UniValue& titleValue = prop_data.find_value("name"); titleValue.isStr()) {
m_title = QString::fromStdString(titleValue.get_str());
}

if (UniValue paymentStartValue = prop_data.find_value("start_epoch"); paymentStartValue.isNum()) {
if (const UniValue& paymentStartValue = prop_data.find_value("start_epoch"); paymentStartValue.isNum()) {
m_startDate = QDateTime::fromSecsSinceEpoch(paymentStartValue.getInt<int64_t>());
}

if (UniValue paymentEndValue = prop_data.find_value("end_epoch"); paymentEndValue.isNum()) {
if (const UniValue& paymentEndValue = prop_data.find_value("end_epoch"); paymentEndValue.isNum()) {
m_endDate = QDateTime::fromSecsSinceEpoch(paymentEndValue.getInt<int64_t>());
}

if (UniValue amountValue = prop_data.find_value("payment_amount"); amountValue.isNum()) {
if (const UniValue& amountValue = prop_data.find_value("payment_amount"); amountValue.isNum()) {
m_paymentAmount = amountValue.get_real();
}

if (UniValue urlValue = prop_data.find_value("url"); urlValue.isStr()) {
if (const UniValue& urlValue = prop_data.find_value("url"); urlValue.isStr()) {
m_url = QString::fromStdString(urlValue.get_str());
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/qt/splashscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ SplashScreen::SplashScreen(const NetworkStyle *networkStyle) :
// define text to place
QString titleText = PACKAGE_NAME;
QString versionText = QString::fromStdString(FormatFullVersion()).remove(0, 1);
QString titleAddText = networkStyle->getTitleAddText();
const QString& titleAddText = networkStyle->getTitleAddText();

QFont fontNormal = GUIUtil::getFontNormal();
QFont fontBold = GUIUtil::getFontBold();
Expand Down Expand Up @@ -116,8 +116,7 @@ SplashScreen::SplashScreen(const NetworkStyle *networkStyle) :
int titleAddTextWidth = GUIUtil::TextWidth(fm, titleAddText);
// Draw the badge background with the network-specific color
QRect badgeRect = QRect(width - titleAddTextWidth - 20, 5, width, fm.height() + 10);
QColor badgeColor = networkStyle->getBadgeColor();
pixPaint.fillRect(badgeRect, badgeColor);
pixPaint.fillRect(badgeRect, networkStyle->getBadgeColor());
// Draw the text itself using white color, regardless of the current theme
pixPaint.setPen(QColor(255, 255, 255));
pixPaint.drawText(width - titleAddTextWidth - 10, paddingTop + 10, titleAddText);
Expand Down
1 change: 0 additions & 1 deletion src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#include <cstdint>

using wallet::ISMINE_ALL;
using wallet::ISMINE_SPENDABLE;
using wallet::ISMINE_WATCH_ONLY;
using wallet::isminetype;
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2527,7 +2527,7 @@ static RPCHelpMan scantxoutset()
for (const UniValue& scanobject : request.params[1].get_array().getValues()) {
FlatSigningProvider provider;
auto scripts = EvalDescriptorStringOrObject(scanobject, provider);
for (const auto& script : scripts) {
for (CScript& script : scripts) {
std::string inferred = InferDescriptor(script, provider)->ToString();
needles.emplace(script);
descriptors.emplace(std::move(script), std::move(inferred));
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/coinjoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static RPCHelpMan coinjoin_status()
}

UniValue ret(UniValue::VARR);
for (auto str_status : cj_clientman->getSessionStatuses()) {
for (const auto& str_status : cj_clientman->getSessionStatuses()) {
ret.push_back(str_status);
}
return ret;
Expand Down
2 changes: 0 additions & 2 deletions src/rpc/evo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ using node::NodeContext;
using wallet::CWallet;
#ifdef ENABLE_WALLET
using wallet::CCoinControl;
using wallet::CoinType;
using wallet::COutput;
using wallet::CRecipient;
using wallet::DEFAULT_DISABLE_WALLET;
using wallet::GetWalletForJSONRPCRequest;
Expand Down
1 change: 0 additions & 1 deletion src/rpc/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ using node::ReadBlockFromDisk;
#ifdef ENABLE_WALLET
using wallet::CCoinControl;
using wallet::CoinType;
using wallet::COutput;
using wallet::CWallet;
using wallet::GetWalletForJSONRPCRequest;
#endif // ENABLE_WALLET
Expand Down
6 changes: 3 additions & 3 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static bool GenerateBlock(ChainstateManager& chainman, CBlock& block, uint64_t&
block_hash.SetNull();
block.hashMerkleRoot = BlockMerkleRoot(block);

CChainParams chainparams(Params());
const CChainParams& chainparams(Params());

while (max_tries > 0 && block.nNonce < std::numeric_limits<uint32_t>::max() && !CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus()) && !ShutdownRequested()) {
++block.nNonce;
Expand Down Expand Up @@ -356,7 +356,7 @@ static RPCHelpMan generateblock()
}
}

CChainParams chainparams(Params());
const CChainParams& chainparams(Params());
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);

ChainstateManager& chainman = EnsureChainman(node);
Expand Down Expand Up @@ -755,7 +755,7 @@ static RPCHelpMan getblocktemplate()
if (lpval.isStr())
{
// Format: <hashBestChain><nTransactionsUpdatedLast>
std::string lpstr = lpval.get_str();
const std::string& lpstr = lpval.get_str();

hashWatchedChain = ParseHashV(lpstr.substr(0, 64), "longpollid");
nTransactionsUpdatedLastLP = LocaleIndependentAtoi<int64_t>(lpstr.substr(64));
Expand Down
5 changes: 0 additions & 5 deletions src/rpc/output_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
#include <string>
#include <vector>

namespace node {
struct NodeContext;
}
using node::NodeContext;

static RPCHelpMan validateaddress()
{
return RPCHelpMan{
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/rawtransaction_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ static void TxInErrorToJSON(const CTxIn& txin, UniValue& vErrorsRet, const std::
void ParsePrevouts(const UniValue& prevTxsUnival, FillableSigningProvider* keystore, std::map<COutPoint, Coin>& coins)
{
if (!prevTxsUnival.isNull()) {
UniValue prevTxs = prevTxsUnival.get_array();
const UniValue& prevTxs = prevTxsUnival.get_array();
for (unsigned int idx = 0; idx < prevTxs.size(); ++idx) {
const UniValue& p = prevTxs[idx];
if (!p.isObject()) {
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "expected object with {\"txid'\",\"vout\",\"scriptPubKey\"}");
}

UniValue prevOut = p.get_obj();
const UniValue& prevOut = p.get_obj();

RPCTypeCheckObj(prevOut,
{
Expand Down
Loading
Loading