From 37af70a188207f55582dc8e8bda585d9841b3897 Mon Sep 17 00:00:00 2001 From: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com> Date: Sat, 12 Sep 2020 14:33:54 +0000 Subject: [PATCH] Merge #13622: Remove mapRequest tracking that just effects Qt display. (#3694) * Merge #13622: Remove mapRequest tracking that just effects Qt display. beef7ec4be725beea870a2da510d2817487601ec Remove useless mapRequest tracking that just effects Qt display. (Matt Corallo) Pull request description: I thought we had removed this a long time ago, TBH, its really confusing feedback to users that we display whether a tx was broadcast to immediate neighbor nodes, given that has little indication of whether the tx propagated very far. Tree-SHA512: c9d0808fb60146919bb78d0860ec2193601966c944887eaae7837408422f7e85dfdb306407a613200cdd4726aec66da18df618ebc6a8cfe8650bf08d4a8dc155 Signed-off-by: pasta * drop TX_STATUS_OFFLINE Signed-off-by: pasta Co-authored-by: Wladimir J. van der Laan --- src/net_processing.cpp | 6 ----- src/qt/guiutil.cpp | 2 -- src/qt/guiutil.h | 2 -- src/qt/transactiondesc.cpp | 13 +--------- src/qt/transactionrecord.cpp | 8 ------ src/qt/transactionrecord.h | 4 +-- src/qt/transactiontablemodel.cpp | 9 ------- src/validationinterface.cpp | 10 -------- src/validationinterface.h | 7 ------ src/wallet/wallet.cpp | 42 -------------------------------- src/wallet/wallet.h | 12 --------- 11 files changed, 2 insertions(+), 113 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index ea5012c76a..40285fef21 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1674,9 +1674,6 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm if (!push) vNotFound.push_back(inv); - - // Track requests for our stuff. - GetMainSignals().Inventory(inv.hash); } } // release cs_main @@ -2511,9 +2508,6 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr } } } - - // Track requests for our stuff - GetMainSignals().Inventory(inv.hash); } return true; } diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index bbd6af975f..096c5dc61e 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -160,7 +160,6 @@ static const std::map themedColors = { { ThemedColor::GREEN, QColor(8, 110, 3) }, { ThemedColor::BAREADDRESS, QColor(140, 140, 140) }, { ThemedColor::TX_STATUS_OPENUNTILDATE, QColor(64, 64, 255) }, - { ThemedColor::TX_STATUS_OFFLINE, QColor(192, 192, 192) }, { ThemedColor::TX_STATUS_DANGER, QColor(168, 72, 50) }, { ThemedColor::TX_STATUS_LOCKED, QColor(28, 117, 188) }, { ThemedColor::BACKGROUND_WIDGET, QColor(234, 234, 236) }, @@ -176,7 +175,6 @@ static const std::map themedDarkColors = { { ThemedColor::GREEN, QColor(8, 110, 3) }, { ThemedColor::BAREADDRESS, QColor(140, 140, 140) }, { ThemedColor::TX_STATUS_OPENUNTILDATE, QColor(64, 64, 255) }, - { ThemedColor::TX_STATUS_OFFLINE, QColor(192, 192, 192) }, { ThemedColor::TX_STATUS_DANGER, QColor(168, 72, 50) }, { ThemedColor::TX_STATUS_LOCKED, QColor(28, 117, 188) }, { ThemedColor::BACKGROUND_WIDGET, QColor(45, 45, 46) }, diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index bd319567f1..5cd669a853 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -50,8 +50,6 @@ namespace GUIUtil BAREADDRESS, /* Transaction list -- TX status decoration - open until date */ TX_STATUS_OPENUNTILDATE, - /* Transaction list -- TX status decoration - offline */ - TX_STATUS_OFFLINE, /* Transaction list -- TX status decoration - danger, tx needs attention */ TX_STATUS_DANGER, /* Transaction list -- TX status decoration - LockedByInstantSend color */ diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 4220334b1d..5080d96234 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -38,12 +38,9 @@ QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx) if (nDepth < 0) return tr("conflicted"); QString strTxStatus; - bool fOffline = (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60) && (wtx.GetRequestCount() == 0); bool fChainLocked = wtx.IsChainLocked(); - if (fOffline) { - strTxStatus = tr("%1/offline").arg(nDepth); - } else if (nDepth == 0) { + if (nDepth == 0) { strTxStatus = tr("0/unconfirmed, %1").arg((wtx.InMempool() ? tr("in memory pool") : tr("not in memory pool"))) + (wtx.isAbandoned() ? ", "+tr("abandoned") : ""); } else if (!fChainLocked && nDepth < 6) { strTxStatus = tr("%1/unconfirmed").arg(nDepth); @@ -77,14 +74,6 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco CAmount nNet = nCredit - nDebit; strHTML += "" + tr("Status") + ": " + FormatTxStatus(wtx); - int nRequests = wtx.GetRequestCount(); - if (nRequests != -1) - { - if (nRequests == 0) - strHTML += tr(", has not been successfully broadcast yet"); - else if (nRequests > 0) - strHTML += tr(", broadcast through %n node(s)", "", nRequests); - } strHTML += "
"; strHTML += "" + tr("Date") + ": " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "
"; diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index b42c1a4467..e051efc507 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -319,10 +319,6 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx, int chainLockHeight) if (wtx.IsInMainChain()) { status.matures_in = wtx.GetBlocksToMaturity(); - - // Check if the block was requested by anyone - if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) - status.status = TransactionStatus::MaturesWarning; } else { @@ -351,10 +347,6 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx, int chainLockHeight) { status.status = TransactionStatus::Conflicted; } - else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0) - { - status.status = TransactionStatus::Offline; - } else if (status.depth == 0) { status.status = TransactionStatus::Unconfirmed; diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h index 22c322a1ee..168df7170d 100644 --- a/src/qt/transactionrecord.h +++ b/src/qt/transactionrecord.h @@ -22,7 +22,7 @@ class TransactionStatus public: TransactionStatus(): countsForBalance(false), lockedByInstantSend(false), lockedByChainLocks(false), sortKey(""), - matures_in(0), status(Offline), depth(0), open_for(0), cur_num_blocks(-1), + matures_in(0), status(Unconfirmed), depth(0), open_for(0), cur_num_blocks(-1), cachedChainLockHeight(-1), needsUpdate(false) { } @@ -31,14 +31,12 @@ public: /// Normal (sent/received) transactions OpenUntilDate, /**< Transaction not yet final, waiting for date */ OpenUntilBlock, /**< Transaction not yet final, waiting for block */ - Offline, /**< Not sent to any other nodes **/ Unconfirmed, /**< Not yet mined into a block **/ Confirming, /**< Confirmed, but waiting for the recommended number of confirmations **/ Conflicted, /**< Conflicts with other transaction or mempool **/ Abandoned, /**< Abandoned from the wallet **/ /// Generated (mined) transactions Immature, /**< Mined but waiting for maturity */ - MaturesWarning, /**< Transaction will likely not mature because no nodes have confirmed */ NotAccepted /**< Mined but not accepted */ }; diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 9990da5f91..4f48ae62b5 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -336,9 +336,6 @@ QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) cons case TransactionStatus::OpenUntilDate: status = tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx->status.open_for)); break; - case TransactionStatus::Offline: - status = tr("Offline"); - break; case TransactionStatus::Unconfirmed: status = tr("Unconfirmed"); break; @@ -357,9 +354,6 @@ QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) cons case TransactionStatus::Immature: status = tr("Immature (%1 confirmations, will be available after %2)").arg(wtx->status.depth).arg(wtx->status.depth + wtx->status.matures_in); break; - case TransactionStatus::MaturesWarning: - status = tr("This block was not received by any other nodes and will probably not be accepted!"); - break; case TransactionStatus::NotAccepted: status = tr("Generated but not accepted"); break; @@ -520,8 +514,6 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx) case TransactionStatus::OpenUntilBlock: case TransactionStatus::OpenUntilDate: return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::TX_STATUS_OPENUNTILDATE); - case TransactionStatus::Offline: - return GUIUtil::getThemedQColor(GUIUtil::ThemedColor::TX_STATUS_OFFLINE); case TransactionStatus::Unconfirmed: return QIcon(":/icons/transaction_0"); case TransactionStatus::Abandoned: @@ -544,7 +536,6 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx) int part = (wtx->status.depth * 5 / total) + 1; return QIcon(QString(":/icons/transaction_%1").arg(part)); } - case TransactionStatus::MaturesWarning: case TransactionStatus::NotAccepted: return QIcon(":/icons/transaction_0"); default: diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp index fc7ae76060..3482aec06c 100644 --- a/src/validationinterface.cpp +++ b/src/validationinterface.cpp @@ -27,7 +27,6 @@ struct MainSignalsInstance { boost::signals2::signal &, const CBlockIndex* pindexDisconnected)> BlockDisconnected; boost::signals2::signal TransactionRemovedFromMempool; boost::signals2::signal SetBestChain; - boost::signals2::signal Inventory; boost::signals2::signal Broadcast; boost::signals2::signal BlockChecked; boost::signals2::signal&)> NewPoWValidBlock; @@ -94,7 +93,6 @@ void RegisterValidationInterface(CValidationInterface* pwalletIn) { g_signals.m_internals->NotifyChainLock.connect(boost::bind(&CValidationInterface::NotifyChainLock, pwalletIn, _1, _2)); g_signals.m_internals->TransactionRemovedFromMempool.connect(boost::bind(&CValidationInterface::TransactionRemovedFromMempool, pwalletIn, _1)); g_signals.m_internals->SetBestChain.connect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1)); - g_signals.m_internals->Inventory.connect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1)); g_signals.m_internals->Broadcast.connect(boost::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn, _1, _2)); g_signals.m_internals->BlockChecked.connect(boost::bind(&CValidationInterface::BlockChecked, pwalletIn, _1, _2)); g_signals.m_internals->NewPoWValidBlock.connect(boost::bind(&CValidationInterface::NewPoWValidBlock, pwalletIn, _1, _2)); @@ -107,7 +105,6 @@ void RegisterValidationInterface(CValidationInterface* pwalletIn) { void UnregisterValidationInterface(CValidationInterface* pwalletIn) { g_signals.m_internals->BlockChecked.disconnect(boost::bind(&CValidationInterface::BlockChecked, pwalletIn, _1, _2)); g_signals.m_internals->Broadcast.disconnect(boost::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn, _1, _2)); - g_signals.m_internals->Inventory.disconnect(boost::bind(&CValidationInterface::Inventory, pwalletIn, _1)); g_signals.m_internals->SetBestChain.disconnect(boost::bind(&CValidationInterface::SetBestChain, pwalletIn, _1)); g_signals.m_internals->NotifyChainLock.disconnect(boost::bind(&CValidationInterface::NotifyChainLock, pwalletIn, _1, _2)); g_signals.m_internals->NotifyTransactionLock.disconnect(boost::bind(&CValidationInterface::NotifyTransactionLock, pwalletIn, _1, _2)); @@ -132,7 +129,6 @@ void UnregisterAllValidationInterfaces() { } g_signals.m_internals->BlockChecked.disconnect_all_slots(); g_signals.m_internals->Broadcast.disconnect_all_slots(); - g_signals.m_internals->Inventory.disconnect_all_slots(); g_signals.m_internals->SetBestChain.disconnect_all_slots(); g_signals.m_internals->NotifyTransactionLock.disconnect_all_slots(); g_signals.m_internals->NotifyChainLock.disconnect_all_slots(); @@ -207,12 +203,6 @@ void CMainSignals::SetBestChain(const CBlockLocator &locator) { }); } -void CMainSignals::Inventory(const uint256 &hash) { - m_internals->m_schedulerClient.AddToProcessQueue([hash, this] { - m_internals->Inventory(hash); - }); -} - void CMainSignals::Broadcast(int64_t nBestBlockTime, CConnman* connman) { m_internals->Broadcast(nBestBlockTime, connman); } diff --git a/src/validationinterface.h b/src/validationinterface.h index 236f6c6657..1c1fda7748 100644 --- a/src/validationinterface.h +++ b/src/validationinterface.h @@ -117,12 +117,6 @@ protected: * Called on a background thread. */ virtual void SetBestChain(const CBlockLocator &locator) {} - /** - * Notifies listeners about an inventory item being seen on the network. - * - * Called on a background thread. - */ - virtual void Inventory(const uint256 &hash) {} /** Tells listeners to broadcast their data. */ virtual void ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman) {} /** @@ -182,7 +176,6 @@ public: void NotifyInstantSendDoubleSpendAttempt(const CTransaction ¤tTx, const CTransaction &previousTx); void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff); void SetBestChain(const CBlockLocator &); - void Inventory(const uint256 &); void Broadcast(int64_t nBestBlockTime, CConnman* connman); void BlockChecked(const CBlock&, const CValidationState&); void NewPoWValidBlock(const CBlockIndex *, const std::shared_ptr&); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 9a7ce0b299..203037da81 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1901,45 +1901,6 @@ int64_t CWalletTx::GetTxTime() const return n ? n : nTimeReceived; } -int CWalletTx::GetRequestCount() const -{ - // Returns -1 if it wasn't being tracked - int nRequests = -1; - { - LOCK(pwallet->cs_wallet); - if (IsCoinBase()) - { - // Generated block - if (!hashUnset()) - { - std::map::const_iterator mi = pwallet->mapRequestCount.find(hashBlock); - if (mi != pwallet->mapRequestCount.end()) - nRequests = (*mi).second; - } - } - else - { - // Did anyone request this transaction? - std::map::const_iterator mi = pwallet->mapRequestCount.find(GetHash()); - if (mi != pwallet->mapRequestCount.end()) - { - nRequests = (*mi).second; - - // How about the block it's in? - if (nRequests == 0 && !hashUnset()) - { - std::map::const_iterator _mi = pwallet->mapRequestCount.find(hashBlock); - if (_mi != pwallet->mapRequestCount.end()) - nRequests = (*_mi).second; - else - nRequests = 1; // If it's in someone else's block it must have got out - } - } - } - } - return nRequests; -} - void CWalletTx::GetAmounts(std::list& listReceived, std::list& listSent, CAmount& nFee, std::string& strSentAccount, const isminefilter& filter) const { @@ -4093,9 +4054,6 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, CCon } } - // Track how many getdata requests our transaction gets - mapRequestCount[wtxNew.GetHash()] = 0; - // Get the inserted-CWalletTx from mapWallet so that the // fInMempool flag is cached properly CWalletTx& wtx = mapWallet[wtxNew.GetHash()]; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 600bbea3f7..4b63738006 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -505,7 +505,6 @@ public: bool IsTrusted() const; int64_t GetTxTime() const; - int GetRequestCount() const; // RelayWalletTransaction may only be called if fBroadcastTransactions! bool RelayWalletTransaction(CConnman* connman); @@ -882,7 +881,6 @@ public: int64_t nOrderPosNext; uint64_t nAccountingEntryNumber; - std::map mapRequestCount; std::map mapAddressBook; @@ -1137,16 +1135,6 @@ public: const std::string& GetAccountName(const CScript& scriptPubKey) const; - void Inventory(const uint256 &hash) override - { - { - LOCK(cs_wallet); - std::map::iterator mi = mapRequestCount.find(hash); - if (mi != mapRequestCount.end()) - (*mi).second++; - } - } - void GetScriptForMining(std::shared_ptr &script); unsigned int GetKeyPoolSize()