From bfff1d0903c9b75bd8cca27321d7a13fd5bfab6c Mon Sep 17 00:00:00 2001 From: Peter Bushnell Date: Mon, 30 May 2022 11:05:12 +0100 Subject: [PATCH] Silence most compiler warnings --- src/bench/bench_defi.cpp | 2 ++ src/flushablestorage.h | 2 +- src/masternodes/anchors.cpp | 2 +- src/masternodes/loan.cpp | 6 +++--- src/masternodes/masternodes.cpp | 4 ++-- src/masternodes/mn_checks.cpp | 12 ++++++------ src/masternodes/poolpairs.cpp | 2 +- src/masternodes/rpc_accounts.cpp | 13 ++++++++----- src/masternodes/rpc_icxorderbook.cpp | 2 +- src/masternodes/rpc_loan.cpp | 3 +-- src/masternodes/rpc_masternodes.cpp | 2 +- src/masternodes/rpc_oracles.cpp | 6 +++--- src/masternodes/rpc_vault.cpp | 4 ++-- src/net_processing.cpp | 2 +- src/pos.cpp | 6 +++--- src/spv/spv_rpc.cpp | 2 +- src/test/anchor_tests.cpp | 4 ++-- src/test/liquidity_tests.cpp | 2 +- src/validation.cpp | 26 +++++++++++++------------- src/wallet/wallet.cpp | 3 --- 20 files changed, 53 insertions(+), 52 deletions(-) diff --git a/src/bench/bench_defi.cpp b/src/bench/bench_defi.cpp index 8b0de86893..c07e6f68e9 100644 --- a/src/bench/bench_defi.cpp +++ b/src/bench/bench_defi.cpp @@ -9,6 +9,7 @@ #include +/* static const int64_t DEFAULT_BENCH_EVALUATIONS = 5; static const char* DEFAULT_BENCH_FILTER = ".*"; static const char* DEFAULT_BENCH_SCALING = "1.0"; @@ -30,6 +31,7 @@ static void SetupBenchArgs() gArgs.AddArg("-plot-width=", strprintf("Plot width in pixel (default: %u)", DEFAULT_PLOT_WIDTH), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); gArgs.AddArg("-plot-height=", strprintf("Plot height in pixel (default: %u)", DEFAULT_PLOT_HEIGHT), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); } + */ int main(int argc, char** argv) { diff --git a/src/flushablestorage.h b/src/flushablestorage.h index c9a9ffcea1..eae64b9977 100644 --- a/src/flushablestorage.h +++ b/src/flushablestorage.h @@ -483,7 +483,7 @@ class CStorageView { // second type of 'ReadBy' (may be 'GetBy'?) template boost::optional ReadBy(KeyType const & id) const { - ResultType result; + ResultType result{}; if (ReadBy(id, result)) return {result}; return {}; diff --git a/src/masternodes/anchors.cpp b/src/masternodes/anchors.cpp index 6b357aa0a6..6f873f65fa 100644 --- a/src/masternodes/anchors.cpp +++ b/src/masternodes/anchors.cpp @@ -878,7 +878,7 @@ bool ContextualValidateAnchor(const CAnchorData &anchor, CBlockIndex& anchorBloc } // Recreate deeper anchor depth - if (anchorCreationHeight >= Params().GetConsensus().FortCanningHeight) { + if (anchorCreationHeight >= static_cast(Params().GetConsensus().FortCanningHeight)) { timeDepth += Params().GetConsensus().mn.anchoringAdditionalTimeDepth; while (anchorHeight > 0 && ::ChainActive()[anchorHeight]->nTime + timeDepth > anchorCreationBlock->nTime) { --anchorHeight; diff --git a/src/masternodes/loan.cpp b/src/masternodes/loan.cpp index 7a63a4620d..05d9b9b236 100644 --- a/src/masternodes/loan.cpp +++ b/src/masternodes/loan.cpp @@ -186,7 +186,7 @@ void CLoanView::EraseDelayedDestroyScheme(const std::string& loanSchemeID) boost::optional CLoanView::GetInterestRate(const CVaultId& vaultId, DCT_ID id, uint32_t height) { - if (height >= Params().GetConsensus().FortCanningHillHeight) + if (height >= static_cast(Params().GetConsensus().FortCanningHillHeight)) return ReadBy(std::make_pair(vaultId, id)); if (auto rate = ReadBy(std::make_pair(vaultId, id))) @@ -251,7 +251,7 @@ CAmount InterestPerBlock(const CInterestRateV2& rate, uint32_t height) void CLoanView::WriteInterestRate(const std::pair& pair, const CInterestRateV2& rate, uint32_t height) { - if (height >= Params().GetConsensus().FortCanningHillHeight) + if (height >= static_cast(Params().GetConsensus().FortCanningHillHeight)) WriteBy(pair, rate); else WriteBy(pair, ConvertInterestRateToV1(rate)); @@ -376,7 +376,7 @@ void DeleteInterest(CLoanView& view, const CVaultId& vaultId) Res CLoanView::DeleteInterest(const CVaultId& vaultId, uint32_t height) { - if (height >= Params().GetConsensus().FortCanningHillHeight) + if (height >= static_cast(Params().GetConsensus().FortCanningHillHeight)) ::DeleteInterest(*this, vaultId); else ::DeleteInterest(*this, vaultId); diff --git a/src/masternodes/masternodes.cpp b/src/masternodes/masternodes.cpp index 066b015830..05a88fd2d9 100644 --- a/src/masternodes/masternodes.cpp +++ b/src/masternodes/masternodes.cpp @@ -461,7 +461,7 @@ std::vector CMasternodesView::GetSubNodesBlockTime(const CKeyID & minte for (uint8_t i{0}; i < SUBNODE_COUNT; ++i) { ForEachSubNode([&](const SubNodeBlockTimeKey &key, int64_t blockTime) { - if (height >= Params().GetConsensus().FortCanningHeight) { + if (height >= static_cast(Params().GetConsensus().FortCanningHeight)) { if (key.masternodeID == nodeId && key.subnode == i) { times[i] = blockTime; } @@ -522,7 +522,7 @@ uint16_t CMasternodesView::GetTimelock(const uint256& nodeId, const CMasternode& auto lastHeight = height - 1; // Cannot expire below block count required to calculate average time - if (lastHeight < Params().GetConsensus().mn.newResignDelay) { + if (lastHeight < static_cast(Params().GetConsensus().mn.newResignDelay)) { return *timelock; } diff --git a/src/masternodes/mn_checks.cpp b/src/masternodes/mn_checks.cpp index d2fa4b6e54..d63a63aa97 100644 --- a/src/masternodes/mn_checks.cpp +++ b/src/masternodes/mn_checks.cpp @@ -1087,7 +1087,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor updatedToken.creationTx = token.creationTx; updatedToken.destructionTx = token.destructionTx; updatedToken.destructionHeight = token.destructionHeight; - if (height >= consensus.FortCanningHeight) { + if (height >= static_cast(consensus.FortCanningHeight)) { updatedToken.symbol = trim_ws(updatedToken.symbol).substr(0, CToken::MAX_TOKEN_SYMBOL_LENGTH); } @@ -1158,7 +1158,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor return Res::Err("token %s does not exist!", poolPair.idTokenB.ToString()); } - const auto symbolLength = height >= consensus.FortCanningHeight ? CToken::MAX_TOKEN_POOLPAIR_LENGTH : CToken::MAX_TOKEN_SYMBOL_LENGTH; + const auto symbolLength = height >= static_cast(consensus.FortCanningHeight) ? CToken::MAX_TOKEN_POOLPAIR_LENGTH : CToken::MAX_TOKEN_SYMBOL_LENGTH; if (pairSymbol.empty()) { pairSymbol = trim_ws(tokenA->symbol + "-" + tokenB->symbol).substr(0, symbolLength); } else { @@ -3886,7 +3886,7 @@ Res ApplyCustomTx(CCustomCSView& mnview, const CCoinsViewCache& coins, const CTr return res; } std::vector metadata; - const auto metadataValidation = height >= consensus.FortCanningHeight; + const auto metadataValidation = height >= static_cast(consensus.FortCanningHeight); auto txType = GuessCustomTxType(tx, metadata, metadataValidation); if (txType == CustomTxType::None) { @@ -3928,7 +3928,7 @@ Res ApplyCustomTx(CCustomCSView& mnview, const CCoinsViewCache& coins, const CTr } res.code |= CustomTxErrCodes::Fatal; } - if (height >= consensus.DakotaHeight) { + if (height >= static_cast(consensus.DakotaHeight)) { res.code |= CustomTxErrCodes::Fatal; } return res; @@ -4216,7 +4216,7 @@ Res CPoolSwap::ExecuteSwap(CCustomCSView& view, std::vector poolIDs, boo Res poolResult = Res::Ok(); // No composite swap allowed before Fort Canning - if (height < Params().GetConsensus().FortCanningHeight && !poolIDs.empty()) { + if (height < static_cast(Params().GetConsensus().FortCanningHeight) && !poolIDs.empty()) { poolIDs.clear(); } @@ -4354,7 +4354,7 @@ Res CPoolSwap::ExecuteSwap(CCustomCSView& view, std::vector poolIDs, boo } // Reject if price paid post-swap above max price provided - if (height >= Params().GetConsensus().FortCanningHeight && obj.maxPrice != POOLPRICE_MAX) { + if (height >= static_cast(Params().GetConsensus().FortCanningHeight) && obj.maxPrice != POOLPRICE_MAX) { if (swapAmountResult.nValue != 0) { const auto userMaxPrice = arith_uint256(obj.maxPrice.integer) * COIN + obj.maxPrice.fraction; if (arith_uint256(obj.amountFrom) * COIN / swapAmountResult.nValue > userMaxPrice) { diff --git a/src/masternodes/poolpairs.cpp b/src/masternodes/poolpairs.cpp index 917d917262..d3145edc9f 100644 --- a/src/masternodes/poolpairs.cpp +++ b/src/masternodes/poolpairs.cpp @@ -245,7 +245,7 @@ void CPoolPairView::CalculatePoolRewards(DCT_ID const & poolId, std::function(poolKey); - PoolSwapValue poolSwap; + PoolSwapValue poolSwap{}; auto nextPoolSwap = UINT_MAX; auto poolSwapHeight = UINT_MAX; auto itPoolSwap = LowerBound(poolKey); diff --git a/src/masternodes/rpc_accounts.cpp b/src/masternodes/rpc_accounts.cpp index 84f3de68e5..4db4d59b52 100644 --- a/src/masternodes/rpc_accounts.cpp +++ b/src/masternodes/rpc_accounts.cpp @@ -528,8 +528,8 @@ UniValue gettokenbalances(const JSONRPCRequest& request) { return true; }); auto it = totalBalances.balances.lower_bound(start); - for (int i = 0; it != totalBalances.balances.end() && i < limit; it++, i++) { - CTokenAmount bal = CTokenAmount{(*it).first, (*it).second}; + for (size_t i = 0; it != totalBalances.balances.end() && i < limit; it++, i++) { + auto bal = CTokenAmount{(*it).first, (*it).second}; std::string tokenIdStr = bal.nTokenId.ToString(); if (symbol_lookup) { auto token = mnview.GetToken(bal.nTokenId); @@ -1191,10 +1191,13 @@ UniValue listaccounthistory(const JSONRPCRequest& request) { count = limit; searchInWallet(pwallet, account, filter, [&](CBlockIndex const * index, CWalletTx const * pwtx) { - return txs.count(pwtx->GetHash()) || startBlock > index->nHeight || index->nHeight > maxBlockHeight; + uint32_t height = index->nHeight; + return txs.count(pwtx->GetHash()) || startBlock > height || height > maxBlockHeight; }, [&](COutputEntry const & entry, CBlockIndex const * index, CWalletTx const * pwtx) { - if (txn != std::numeric_limits::max() && index->nHeight == maxBlockHeight && pwtx->nIndex > txn ) { + uint32_t height = index->nHeight; + uint32_t nIndex = pwtx->nIndex; + if (txn != std::numeric_limits::max() && height == maxBlockHeight && nIndex > txn ) { return true; } auto& array = ret.emplace(index->nHeight, UniValue::VARR).first->second; @@ -1563,7 +1566,7 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { if (shouldSearchInWallet) { searchInWallet(pwallet, owner, filter, [&](CBlockIndex const * index, CWalletTx const * pwtx) { - return txs.count(pwtx->GetHash()) || index->nHeight > currentHeight; + return txs.count(pwtx->GetHash()) || static_cast(index->nHeight) > currentHeight; }, [&count](COutputEntry const &, CBlockIndex const *, CWalletTx const *) { ++count; diff --git a/src/masternodes/rpc_icxorderbook.cpp b/src/masternodes/rpc_icxorderbook.cpp index 531aaf3ab6..d48f4bddbd 100644 --- a/src/masternodes/rpc_icxorderbook.cpp +++ b/src/masternodes/rpc_icxorderbook.cpp @@ -44,7 +44,7 @@ UniValue icxOrderToJSON(CICXOrderImplemetation const& order, uint8_t const statu orderObj.pushKV("closeHeight", static_cast(order.closeHeight)); if (!order.closeTx.IsNull()) orderObj.pushKV("closeTx", order.closeTx.GetHex()); } - else if (order.creationHeight + order.expiry <= pcustomcsview->GetLastHeight()) + else if (order.creationHeight + order.expiry <= static_cast(pcustomcsview->GetLastHeight())) { orderObj.pushKV("expired", true); } diff --git a/src/masternodes/rpc_loan.cpp b/src/masternodes/rpc_loan.cpp index 1aa47df786..4465fba022 100644 --- a/src/masternodes/rpc_loan.cpp +++ b/src/masternodes/rpc_loan.cpp @@ -1417,7 +1417,7 @@ UniValue getinterest(const JSONRPCRequest& request) { throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Token %s does not exist!", tokenStr)); UniValue ret(UniValue::VARR); - uint32_t height = ::ChainActive().Height() + 1; + const auto height = ::ChainActive().Height() + 1; std::map, base_uint<128>> > interest; @@ -1453,7 +1453,6 @@ UniValue getinterest(const JSONRPCRequest& request) { for (auto it=interest.begin(); it != interest.end(); ++it) { auto tokenId = it->first; - auto interestRate = it->second; auto totalInterest = it->second.first; auto interestPerBlock = it->second.second; diff --git a/src/masternodes/rpc_masternodes.cpp b/src/masternodes/rpc_masternodes.cpp index 1b9e26004a..12d8326e8f 100644 --- a/src/masternodes/rpc_masternodes.cpp +++ b/src/masternodes/rpc_masternodes.cpp @@ -808,7 +808,7 @@ UniValue getmasternodeblocks(const JSONRPCRequest& request) { depth = std::min(depth, currentHeight); auto startBlock = currentHeight - depth; - auto masternodeBlocks = [&](const uint256& masternodeID, uint32_t blockHeight) { + auto masternodeBlocks = [&](const uint256& masternodeID, int blockHeight) { if (masternodeID != mn_id) { return false; } diff --git a/src/masternodes/rpc_oracles.cpp b/src/masternodes/rpc_oracles.cpp index 93b3c8c311..4326d5faaf 100644 --- a/src/masternodes/rpc_oracles.cpp +++ b/src/masternodes/rpc_oracles.cpp @@ -529,7 +529,7 @@ UniValue setoracledata(const JSONRPCRequest &request) { } bool diffInHour(int64_t time1, int64_t time2) { - constexpr const uint64_t SECONDS_PER_HOUR = 3600u; + constexpr const int64_t SECONDS_PER_HOUR = 3600u; return std::abs(time1 - time2) < SECONDS_PER_HOUR; } @@ -846,7 +846,7 @@ ResVal GetAggregatePrice(CCustomCSView& view, const std::string& token, return true; }); - static const auto minimumLiveOracles = Params().NetworkIDString() == CBaseChainParams::REGTEST ? 1 : 2; + static const uint64_t minimumLiveOracles = Params().NetworkIDString() == CBaseChainParams::REGTEST ? 1 : 2; if (numLiveOracles < minimumLiveOracles) { return Res::Err("no live oracles for specified request"); @@ -866,7 +866,7 @@ namespace { UniValue GetAllAggregatePrices(CCustomCSView& view, uint64_t lastBlockTime, const UniValue& paginationObj) { size_t limit = 100; - int start = 0; + uint32_t start = 0; bool including_start = true; if (!paginationObj.empty()){ if (!paginationObj["limit"].isNull()) { diff --git a/src/masternodes/rpc_vault.cpp b/src/masternodes/rpc_vault.cpp index 6ee1ef0ab6..7dc9e8bcb2 100644 --- a/src/masternodes/rpc_vault.cpp +++ b/src/masternodes/rpc_vault.cpp @@ -27,7 +27,7 @@ namespace { return "inLiquidation"; case VaultState::MayLiquidate: return "mayLiquidate"; - case VaultState::Unknown: + default: return "unknown"; } } @@ -1220,7 +1220,7 @@ UniValue stateToJSON(VaultStateKey const & key, VaultStateValue const & value) { snapshot.pushKV("state", !value.auctionBatches.empty() ? "inLiquidation" : "active"); snapshot.pushKV("collateralAmounts", AmountsToJSON(value.collaterals)); snapshot.pushKV("collateralValue", ValueFromUint(value.collateralsValues.totalCollaterals)); - snapshot.pushKV("collateralRatio", value.ratio != -1 ? static_cast(value.ratio) : static_cast(value.collateralsValues.ratio())); + snapshot.pushKV("collateralRatio", static_cast(value.ratio != static_cast(-1) ? value.ratio :value.collateralsValues.ratio())); if (!value.auctionBatches.empty()) { snapshot.pushKV("batches", BatchToJSON(value.auctionBatches)); } diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 59b1c324d4..b7b1283635 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2655,7 +2655,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr // possible optimization: stops when first quorum reached (irl, no need to walk deeper) auto topAnchor = panchors->GetActiveAnchor(); // limit requested by the top anchor, if any - if (topAnchor && topAnchor->anchor.height > pLowRequested->nHeight && topAnchor->anchor.height <= (uint64_t) ::ChainActive().Height()) { + if (topAnchor && topAnchor->anchor.height > static_cast(pLowRequested->nHeight) && topAnchor->anchor.height <= (uint64_t) ::ChainActive().Height()) { pLowRequested = ::ChainActive()[topAnchor->anchor.height]; assert(pLowRequested); } diff --git a/src/pos.cpp b/src/pos.cpp index 1ad8d066d8..c432eceb92 100644 --- a/src/pos.cpp +++ b/src/pos.cpp @@ -75,14 +75,14 @@ bool ContextualCheckProofOfStake(const CBlockHeader& blockHeader, const Consensu } creationHeight = int64_t(nodePtr->creationHeight); - if (height >= static_cast(params.EunosPayaHeight)) { + if (height >= params.EunosPayaHeight) { timelock = mnView->GetTimelock(masternodeID, *nodePtr, height); } // Check against EunosPayaHeight here for regtest, does not hurt other networks. // Redundant checks, but intentionally kept for easier fork accounting. - if (height >= static_cast(params.DakotaCrescentHeight) || height >= static_cast(params.EunosPayaHeight)) { - const auto usedHeight = height <= static_cast(params.EunosHeight) ? creationHeight : height; + if (height >= params.DakotaCrescentHeight || height >= params.EunosPayaHeight) { + const auto usedHeight = height <= params.EunosHeight ? creationHeight : height; // Get block times subNodesBlockTime = mnView->GetBlockTimes(nodePtr->operatorAuthAddress, usedHeight, creationHeight, timelock); diff --git a/src/spv/spv_rpc.cpp b/src/spv/spv_rpc.cpp index 6451fe8207..39992aecbe 100644 --- a/src/spv/spv_rpc.cpp +++ b/src/spv/spv_rpc.cpp @@ -473,7 +473,7 @@ UniValue spv_listanchors(const JSONRPCRequest& request) return true; // continue if ((minBtcHeight >= 0 && (int)rec.btcHeight < minBtcHeight) || (maxConfs >= 0 && confs > maxConfs) || - (startBtcHeight >= 0 && static_cast(rec.btcHeight) < startBtcHeight)) + (startBtcHeight >= 0 && rec.btcHeight < static_cast(startBtcHeight))) return false; // break UniValue anchor(UniValue::VOBJ); diff --git a/src/test/anchor_tests.cpp b/src/test/anchor_tests.cpp index f3aa4ced84..3640229d99 100644 --- a/src/test/anchor_tests.cpp +++ b/src/test/anchor_tests.cpp @@ -404,7 +404,7 @@ BOOST_AUTO_TEST_CASE(Test_AnchorFinalMsgCount) CAnchorConfirmDataPlus confirmPlus{confirm}; CAnchorFinalizationMessagePlus finalMsg{confirmPlus}; - for (int i{0}; i < 4 && i < signers.size(); ++i) { + for (size_t i{0}; i < 4 && i < signers.size(); ++i) { CAnchorConfirmMessage confirmMsg{confirmPlus}; signers[i < 3 ? i : i - 1].SignCompact(confirmMsg.GetSignHash(), confirmMsg.signature); finalMsg.sigs.push_back(confirmMsg.signature); @@ -428,7 +428,7 @@ BOOST_AUTO_TEST_CASE(Test_AnchorMsgCount) CAnchorData data{blockHash, 0, blockHash, CAnchorData::CTeam{}}; CAnchor anchor{data}; - for (int i{0}; i < 4 && i < signers.size(); ++i) { + for (size_t i{0}; i < 4 && i < signers.size(); ++i) { CAnchorAuthMessage authMsg{data}; authMsg.SignWithKey(signers[i < 3 ? i : i - 1]); anchor.sigs.push_back(authMsg.GetSignature()); diff --git a/src/test/liquidity_tests.cpp b/src/test/liquidity_tests.cpp index 5da5a4d43a..483510ba15 100644 --- a/src/test/liquidity_tests.cpp +++ b/src/test/liquidity_tests.cpp @@ -478,7 +478,7 @@ BOOST_AUTO_TEST_CASE(owner_rewards) }; mnview.CalculatePoolRewards(idPool, onLiquidity, 1, 10, [&](RewardType type, CTokenAmount amount, uint32_t height) { - if (height >= Params().GetConsensus().BayfrontGardensHeight) { + if (height >= static_cast(Params().GetConsensus().BayfrontGardensHeight)) { if (type == RewardType::Pool) { for (const auto& reward : pool.rewards.balances) { auto providerReward = static_cast((arith_uint256(reward.second) * arith_uint256(onLiquidity()) / arith_uint256(pool.totalLiquidity)).GetLow64()); diff --git a/src/validation.cpp b/src/validation.cpp index df8da7938a..eea0cf3aa8 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1860,7 +1860,7 @@ DisconnectResult CChainState::DisconnectBlock(const CBlock& block, const CBlockI return false; } - if (key.blockHeight != Params().GetConsensus().EunosHeight) { + if (key.blockHeight != static_cast(Params().GetConsensus().EunosHeight)) { return false; } @@ -2928,7 +2928,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl }); std::stringstream poolIdStr; - for (auto i=0; i < poolsToMigrate.size(); i++) { + for (size_t i{0}; i < poolsToMigrate.size(); i++) { if (i != 0) poolIdStr << ", "; poolIdStr << poolsToMigrate[i].ToString(); } @@ -3039,9 +3039,9 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl mnview.IncrementMintedBy(*nodeId); // Store block staker height for use in coinage - if (pindex->nHeight >= static_cast(Params().GetConsensus().EunosPayaHeight)) { + if (pindex->nHeight >= Params().GetConsensus().EunosPayaHeight) { mnview.SetSubNodesBlockTime(minterKey, static_cast(pindex->nHeight), ctxState.subNode, pindex->GetBlockTime()); - } else if (pindex->nHeight >= static_cast(Params().GetConsensus().DakotaCrescentHeight)) { + } else if (pindex->nHeight >= Params().GetConsensus().DakotaCrescentHeight) { mnview.SetMasternodeLastBlockTime(minterKey, static_cast(pindex->nHeight), pindex->GetBlockTime()); } } @@ -3055,7 +3055,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl auto time = GetTimeMillis(); CCustomCSView pruned(mnview); mnview.ForEachUndo([&](UndoKey const & key, CLazySerialize) { - if (key.height >= it->first) { // don't erase checkpoint height + if (key.height >= static_cast(it->first)) { // don't erase checkpoint height return false; } if (!pruneStarted) { @@ -3247,7 +3247,7 @@ void CChainState::ProcessLoanEvents(const CBlockIndex* pindex, CCustomCSView& ca std::vector loanUpdates; cache.ForEachDelayedLoanScheme([&pindex, &loanUpdates](const std::pair& key, const CLoanSchemeMessage& loanScheme) { - if (key.second == pindex->nHeight) { + if (key.second == static_cast(pindex->nHeight)) { loanUpdates.push_back(loanScheme); } return true; @@ -3263,7 +3263,7 @@ void CChainState::ProcessLoanEvents(const CBlockIndex* pindex, CCustomCSView& ca std::vector loanDestruction; cache.ForEachDelayedDestroyScheme([&pindex, &loanDestruction](const std::string& key, const uint64_t& height) { - if (height == pindex->nHeight) { + if (height == static_cast(pindex->nHeight)) { loanDestruction.push_back(key); } return true; @@ -5249,7 +5249,7 @@ bool CChainState::ActivateBestChainStep(CValidationState& state, const CChainPar //check spv and anchors are available and try it first if (spv::pspv && panchors) { auto fallbackAnchor = panchors->GetLatestAnchorUpToDeFiHeight(pindexConnect->nHeight); - if (fallbackAnchor && (fallbackAnchor->anchor.height > fallbackCheckpointBlockHeight)) { + if (fallbackAnchor && (fallbackAnchor->anchor.height > static_cast(fallbackCheckpointBlockHeight))) { blockIndex = LookupBlockIndex(fallbackAnchor->anchor.blockHash); } } @@ -5969,7 +5969,7 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationSta assert(pindexPrev != nullptr); const int nHeight = pindexPrev->nHeight + 1; - if (nHeight >= params.GetConsensus().FortCanningMuseumHeight && nHeight != block.deprecatedHeight) { + if (nHeight >= params.GetConsensus().FortCanningMuseumHeight && static_cast(nHeight) != block.deprecatedHeight) { return state.Invalid(ValidationInvalidReason::BLOCK_INVALID_HEADER, false, REJECT_INVALID, "incorrect-height", "incorrect height set in block header"); } @@ -5991,7 +5991,7 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationSta return state.Invalid(ValidationInvalidReason::BLOCK_INVALID_HEADER, false, REJECT_INVALID, "time-too-old", strprintf("block's timestamp is too early. Block time: %d Min time: %d", block.GetBlockTime(), pindexPrev->GetMedianTimePast())); // Check timestamp - if (Params().NetworkIDString() != CBaseChainParams::REGTEST && nHeight >= static_cast(consensusParams.EunosPayaHeight)) { + if (Params().NetworkIDString() != CBaseChainParams::REGTEST && nHeight >= consensusParams.EunosPayaHeight) { if (block.GetBlockTime() > GetTime() + MAX_FUTURE_BLOCK_TIME_EUNOSPAYA) return state.Invalid(ValidationInvalidReason::BLOCK_TIME_FUTURE, false, REJECT_INVALID, "time-too-new", strprintf("block timestamp too far in the future. Block time: %d Max time: %d", block.GetBlockTime(), GetTime() + MAX_FUTURE_BLOCK_TIME_EUNOSPAYA)); } @@ -5999,7 +5999,7 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationSta if (block.GetBlockTime() > nAdjustedTime + MAX_FUTURE_BLOCK_TIME) return state.Invalid(ValidationInvalidReason::BLOCK_TIME_FUTURE, false, REJECT_INVALID, "time-too-new", "block timestamp too far in the future"); - if (nHeight >= static_cast(consensusParams.DakotaCrescentHeight)) { + if (nHeight >= consensusParams.DakotaCrescentHeight) { if (block.GetBlockTime() > GetTime() + MAX_FUTURE_BLOCK_TIME_DAKOTACRESCENT) return state.Invalid(ValidationInvalidReason::BLOCK_TIME_FUTURE, false, REJECT_INVALID, "time-too-new", strprintf("block timestamp too far in the future. Block time: %d Max time: %d", block.GetBlockTime(), GetTime() + MAX_FUTURE_BLOCK_TIME_DAKOTACRESCENT)); } @@ -6345,14 +6345,14 @@ void ProcessAuthsIfTipChanged(CBlockIndex const * oldTip, CBlockIndex const * ti // Calc how far back team changes, do not generate auths below that height. teamChange = teamChange % Params().GetConsensus().mn.anchoringTeamChange; - uint64_t topAnchorHeight = topAnchor ? static_cast(topAnchor->anchor.height) : 0; + int topAnchorHeight = topAnchor ? static_cast(topAnchor->anchor.height) : 0; // we have no need to ask for auths at all if we have topAnchor higher than current chain if (tip->nHeight <= topAnchorHeight) { return; } CBlockIndex const * pindexFork = ::ChainActive().FindFork(oldTip); - uint64_t forkHeight = pindexFork && (pindexFork->nHeight >= (uint64_t)consensus.mn.anchoringFrequency) ? pindexFork->nHeight - (uint64_t)consensus.mn.anchoringFrequency : 0; + auto forkHeight = pindexFork && pindexFork->nHeight >= consensus.mn.anchoringFrequency ? pindexFork->nHeight - consensus.mn.anchoringFrequency : 0; // limit fork height - trim it by the top anchor, if any forkHeight = std::max(forkHeight, topAnchorHeight); pindexFork = ::ChainActive()[forkHeight]; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d8cc45b392..3caec8e4ad 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3584,11 +3584,8 @@ DBErrors CWallet::ZapWalletTx(std::vector& vWtx) bool CWallet::SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& address, const std::string& strName, const std::string& strPurpose) { - bool fUpdated = false; { LOCK(cs_wallet); - std::map::iterator mi = mapAddressBook.find(address); - fUpdated = mi != mapAddressBook.end(); mapAddressBook[address].name = strName; if (!strPurpose.empty()) /* update purpose only if requested */ mapAddressBook[address].purpose = strPurpose;