From 24b12fa54d89c54cb8898fa45af6de87e497a837 Mon Sep 17 00:00:00 2001 From: BLOCXTECH <134414477+BLOCXTECH@users.noreply.github.com> Date: Mon, 12 Feb 2024 14:12:59 +0530 Subject: [PATCH] Memory pool cache --- README.md | 2 +- src/chainparams.cpp | 2 ++ src/consensus/tx_verify.cpp | 6 ++++ src/evo/deterministicmns.cpp | 42 ++++++++++++++++++++++++++++ src/evo/deterministicmns.h | 24 ++++++++++++++++ src/qt/forms/debugwindow.ui | 54 ++++++++++++++++++++++++------------ src/qt/masternodelist.cpp | 31 +++++++++++++++------ src/qt/rpcconsole.cpp | 12 ++++++-- src/rpc/mining.cpp | 22 +++++++++++++++ 9 files changed, 167 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index bc178d1..23b54fa 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,4 @@ BLOCX. is released under the terms of the MIT license. # Documentation -https://docs.blocx.info/ +https://docs.blocx.info/ \ No newline at end of file diff --git a/src/chainparams.cpp b/src/chainparams.cpp index df6b705..627762e 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -534,6 +534,8 @@ class CMainParams : public CChainParams { {62541, uint256S("0x0000000000000050fd89facd5f17a48b70d188d899483eb0ab5b14cc6e67ece5")}, {74985, uint256S("0x000000000000004cfec6a72a8770d741a06b02532851c46a9e8a587433406f06")}, {85330, uint256S("0x000000000000002e87c0b53d5ce7ea2d27b794330076d2a03555d46cfc46d973")}, + {90281, uint256S("0x000000000000001ce9851e375bc022afb673ad82882a2fb1caa1479e1b7c92fd")}, + {95194, uint256S("0x000000000000002518c37c688a48aaddcdb6db52ab3a19c9efdf7bb70ee82ae8")}, } }; diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp index 87d46aa..4f2317c 100644 --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -156,6 +156,12 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state) allowEmptyTxInOut = true; } + /* The Masternode update service has been temporarily disabled. + User can spend the MN collateral and create Masternode again to start receiving rewards.*/ + if (tx.nType == TRANSACTION_PROVIDER_UPDATE_SERVICE) { + return false; + } + // Basic checks that don't depend on any context if (!allowEmptyTxInOut && tx.vin.empty()) return state.DoS(10, false, REJECT_INVALID, "bad-txns-vin-empty"); diff --git a/src/evo/deterministicmns.cpp b/src/evo/deterministicmns.cpp index d414b34..683d6df 100644 --- a/src/evo/deterministicmns.cpp +++ b/src/evo/deterministicmns.cpp @@ -278,6 +278,48 @@ std::vector CDeterministicMNList::GetProjectedMNPayees(int return result; } +std::vector CDeterministicMNList::GetProjectedMNPayeesTierOne(int nCount) const +{ + if (nCount > GetValidMNsCount()) { + nCount = GetValidMNsCount(); + } + + std::vector result; + result.reserve(nCount); + + ForEachMNTierOne(true, [&](const CDeterministicMNCPtr& dmn) { + result.emplace_back(dmn); + }); + std::sort(result.begin(), result.end(), [&](const CDeterministicMNCPtr& a, const CDeterministicMNCPtr& b) { + return CompareByLastPaid(a, b); + }); + + result.resize(nCount); + + return result; +} + +std::vector CDeterministicMNList::GetProjectedMNPayeesTierTwo(int nCount) const +{ + if (nCount > GetValidMNsCount()) { + nCount = GetValidMNsCount(); + } + + std::vector result; + result.reserve(nCount); + + ForEachMNTierTwo(true, [&](const CDeterministicMNCPtr& dmn) { + result.emplace_back(dmn); + }); + std::sort(result.begin(), result.end(), [&](const CDeterministicMNCPtr& a, const CDeterministicMNCPtr& b) { + return CompareByLastPaid(a, b); + }); + + result.resize(nCount); + + return result; +} + std::vector CDeterministicMNList::CalculateQuorum(size_t maxSize, const uint256& modifier) const { auto scores = CalculateScores(modifier); diff --git a/src/evo/deterministicmns.h b/src/evo/deterministicmns.h index 830d5e7..0151e56 100644 --- a/src/evo/deterministicmns.h +++ b/src/evo/deterministicmns.h @@ -416,6 +416,28 @@ class CDeterministicMNList return tierTwo.size(); } + size_t GetValidStandardMNsCount() const + { + size_t count = 0; + for (const auto& p : tierOne) { + if (IsMNValid(p.second)) { + count++; + } + } + return count; + } + + size_t GetValidLiteMNsCount() const + { + size_t count = 0; + for (const auto& p : tierTwo) { + if (IsMNValid(p.second)) { + count++; + } + } + return count; + } + template void ForEachMN(bool onlyValid, Callback&& cb) const { @@ -481,6 +503,8 @@ class CDeterministicMNList * @return */ std::vector GetProjectedMNPayees(int nCount) const; + std::vector GetProjectedMNPayeesTierOne(int nCount) const; + std::vector GetProjectedMNPayeesTierTwo(int nCount) const; /** * Calculate a quorum based on the modifier. The resulting list is deterministically sorted by score diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui index 357480b..a089a4e 100644 --- a/src/qt/forms/debugwindow.ui +++ b/src/qt/forms/debugwindow.ui @@ -277,7 +277,7 @@ - Number of Masternodes + Number of Standard Masternodes @@ -297,21 +297,41 @@ - + + + + Number of Lite Masternodes + + + + + + + IBeamCursor + + + N/A + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + Block chain - + Current number of blocks - + IBeamCursor @@ -327,14 +347,14 @@ - + Last block time - + IBeamCursor @@ -350,14 +370,14 @@ - + Last block hash - + IBeamCursor @@ -373,21 +393,21 @@ - + Memory Pool - + Current number of transactions - + IBeamCursor @@ -403,14 +423,14 @@ - + Memory usage - + IBeamCursor @@ -466,7 +486,7 @@ - + Qt::Vertical @@ -479,14 +499,14 @@ - + InstantSend locks - + IBeamCursor @@ -1586,4 +1606,4 @@ - + \ No newline at end of file diff --git a/src/qt/masternodelist.cpp b/src/qt/masternodelist.cpp index c818410..6245030 100644 --- a/src/qt/masternodelist.cpp +++ b/src/qt/masternodelist.cpp @@ -202,11 +202,18 @@ void MasternodeList::updateDIP3List() nTimeUpdatedDIP3 = GetTime(); - auto projectedPayees = mnList.GetProjectedMNPayees(mnList.GetValidMNsCount()); - std::map nextPayments; - for (size_t i = 0; i < projectedPayees.size(); i++) { - const auto& dmn = projectedPayees[i]; - nextPayments.emplace(dmn->proTxHash, mnList.GetHeight() + (int)i + 1); + auto projectedPayeesTierOne = mnList.GetProjectedMNPayeesTierOne(mnList.GetAllTierOneMNCount()); + std::map nextPaymentsOne; + for (size_t i = 0; i < projectedPayeesTierOne.size(); i++) { + const auto& dmn = projectedPayeesTierOne[i]; + nextPaymentsOne.emplace(dmn->proTxHash, mnList.GetHeight() + (int)i + 1); + } + + auto projectedPayeesTierTwo = mnList.GetProjectedMNPayeesTierTwo(mnList.GetAllTierTwoMNCount()); + std::map nextPaymentsTwo; + for (size_t i = 0; i < projectedPayeesTierTwo.size(); i++) { + const auto& dmn = projectedPayeesTierTwo[i]; + nextPaymentsTwo.emplace(dmn->proTxHash, mnList.GetHeight() + (int)i + 1); } std::set setOutpts; @@ -240,9 +247,17 @@ void MasternodeList::updateDIP3List() QString strNextPayment = "UNKNOWN"; int nNextPayment = 0; - if (nextPayments.count(dmn->proTxHash)) { - nNextPayment = nextPayments[dmn->proTxHash]; - strNextPayment = QString::number(nNextPayment); + + if (dmn->nType == MnType::Standard_Masternode) { + if (nextPaymentsOne.count(dmn->proTxHash)) { + nNextPayment = nextPaymentsOne[dmn->proTxHash]; + strNextPayment = QString::number(nNextPayment); + } + } else { + if (nextPaymentsTwo.count(dmn->proTxHash)) { + nNextPayment = nextPaymentsTwo[dmn->proTxHash]; + strNextPayment = QString::number(nNextPayment); + } } QTableWidgetItem* nextPaymentItem = new CMasternodeListWidgetItem(strNextPayment, nNextPayment); diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index bef3cc2..087f333 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -977,10 +977,18 @@ void RPCConsole::updateMasternodeCount() return; } auto mnList = clientModel->getMasternodeList(); + size_t total_Standard_mn_count = mnList.GetAllTierOneMNCount(); + size_t total_enabled_Standard_mn_count = mnList.GetValidStandardMNsCount(); + size_t total_lite_mn_count = mnList.GetAllTierTwoMNCount(); + size_t total_enabled_lite_mn_count = mnList.GetValidLiteMNsCount(); QString strMasternodeCount = tr("Total: %1 (Enabled: %2)") - .arg(QString::number(mnList.GetAllMNsCount())) - .arg(QString::number(mnList.GetValidMNsCount())); + .arg(QString::number(total_Standard_mn_count)) + .arg(QString::number(total_enabled_Standard_mn_count)); ui->masternodeCount->setText(strMasternodeCount); + QString strLiteCount = tr("Total: %1 (Enabled: %2)") + .arg(QString::number(total_lite_mn_count)) + .arg(QString::number(total_enabled_lite_mn_count)); + ui->liteCount->setText(strLiteCount); } void RPCConsole::setMempoolSize(long numberOfTxs, size_t dynUsage) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index c3edb52..06f0c70 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -712,6 +712,28 @@ UniValue getblocktemplate(const JSONRPCRequest& request) result.pushKV("superblocks_started", pindexPrev->nHeight + 1 > consensusParams.nSuperblockStartBlock); result.pushKV("superblocks_enabled", AreSuperblocksEnabled()); + { + CScript devPayoutScript = GetScriptForDestination(DecodeDestination(consensusParams.DevelopmentFundAddress)); + CAmount devPayoutValue; + + int nHeight = pindexPrev->nHeight + 1; + + if (nHeight > 18000 && nHeight <= 24000) { + devPayoutValue = (GetBlockSubsidy(0, nHeight, consensusParams) * 18) / 100; + } else if (nHeight <= consensusParams.V3ForkHeight) { + devPayoutValue = (GetBlockSubsidy(0, nHeight, consensusParams) * consensusParams.DevelopementFundShare) / 100; + } else { + devPayoutValue = (GetBlockSubsidy(0, nHeight, consensusParams) * (300.0 / 95.0)) / 100; + } + + UniValue obj(UniValue::VOBJ); + obj.pushKV("payee", (consensusParams.DevelopmentFundAddress).c_str()); + obj.pushKV("script", HexStr(devPayoutScript)); + obj.pushKV("amount", devPayoutValue); + result.pushKV("devfee", obj); + } + + result.pushKV("coinbase_payload", HexStr(pblock->vtx[0]->vExtraPayload)); return result;