From 0207160b3fed4c2f5de62e6aaf6d86fd4b8eef97 Mon Sep 17 00:00:00 2001 From: lateminer <9951982+lateminer@users.noreply.github.com> Date: Thu, 18 Jan 2024 22:50:57 +0100 Subject: [PATCH] cleanup: Remove unused CleanCoinStake() and related functions --- src/node/blockstorage.cpp | 10 ---- src/wallet/wallet.cpp | 102 -------------------------------------- src/wallet/wallet.h | 14 ------ 3 files changed, 126 deletions(-) diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp index 15b006c874..8d966cc6af 100644 --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -730,16 +730,6 @@ void ThreadImport(ChainstateManager& chainman, std::vector vImportFile LogPrintf("Reindexing finished\n"); // To avoid ending up in a situation without genesis block, re-try initializing (no-op if reindexing worked): chainman.ActiveChainstate().LoadGenesisBlock(); - -/* -// TEMP: Blackcoin ToDo: enable/disable! -#ifdef ENABLE_WALLET - // Clean not reverted coinstake transactions - for (const std::shared_ptr& pwallet : GetWallets()) { - pwallet->CleanCoinStake(); - } -#endif -*/ } // -loadblock= diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b59222a064..4aaec60b27 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -740,24 +740,6 @@ void CWallet::AddToSpends(const COutPoint& outpoint, const uint256& wtxid, Walle SyncMetaData(range); } -void CWallet::RemoveFromSpends(const COutPoint& outpoint, const uint256& wtxid) -{ - std::pair range; - range = mapTxSpends.equal_range(outpoint); - TxSpends::iterator it = range.first; - for (; it != range.second; ++ it) - { - if (it->second == wtxid) - { - mapTxSpends.erase(it); - break; - } - } - range = mapTxSpends.equal_range(outpoint); - if (range.first != range.second) - SyncMetaData(range); -} - void CWallet::AddToSpends(const CWalletTx& wtx, WalletBatch* batch) { if (wtx.IsCoinBase()) // Coinbases don't spend anything! @@ -767,17 +749,6 @@ void CWallet::AddToSpends(const CWalletTx& wtx, WalletBatch* batch) AddToSpends(txin.prevout, wtx.GetHash(), batch); } -void CWallet::RemoveFromSpends(const uint256& wtxid) -{ - assert (mapWallet.count(wtxid)); - CWalletTx& thisTx = mapWallet.at(wtxid); - if (thisTx.IsCoinBase()) // Coinbases don't spend anything! - return; - - for (const CTxIn& txin : thisTx.tx->vin) - RemoveFromSpends(txin.prevout, wtxid); -} - bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) { if (IsCrypted()) @@ -1374,20 +1345,6 @@ void CWallet::MarkConflicted(const uint256& hashBlock, int conflicting_height, c void CWallet::SyncTransaction(const CTransactionRef& ptx, const SyncTxState& state, bool update_tx, bool rescanning_old_block) { - /* - // TEMP: Blackcoin ToDo: enable/disable! - if (confirm.hashBlock.IsNull() && confirm.nIndex == -1) - { - // wallets need to refund inputs when disconnecting coinstake - const CTransaction& tx = *ptx; - if (tx.IsCoinStake() && IsFromMe(tx)) - { - DisableTransaction(tx); - return; - } - } - */ - if (!AddToWalletIfInvolvingMe(ptx, state, update_tx, rescanning_old_block)) return; // Not one of ours @@ -2630,35 +2587,6 @@ std::vector CWallet::ListAddrBookAddresses(const std::optionalsecond; - coin.MarkDirty(); - NotifyTransactionChanged(coin.GetHash(), CT_UPDATED); - } - } - CWalletTx& wtx = mapWallet.at(hash); - wtx.MarkDirty(); - NotifyTransactionChanged(hash, CT_DELETED); - } -} -*/ - std::set CWallet::ListAddrBookLabels(const std::optional purpose) const { AssertLockHeld(cs_wallet); @@ -3226,13 +3154,6 @@ std::shared_ptr CWallet::Create(WalletContext& context, const std::stri walletInstance->WalletLogPrintf("m_address_book.size() = %u\n", walletInstance->m_address_book.size()); } - /* - // TEMP: Blackcoin ToDo: enable/disable! - if (!fReindex) - // Clean not reverted coinstake transactions - walletInstance->CleanCoinStake(); - */ - // Flush orphaned coinstakes walletInstance->AbandonOrphanedCoinstakes(); @@ -3905,29 +3826,6 @@ ScriptPubKeyMan* CWallet::AddWalletDescriptor(WalletDescriptor& desc, const Flat return spk_man; } -/* -// TEMP: Blackcoin ToDo: enable/disable! -void CWallet::CleanCoinStake() -{ - LOCK(cs_wallet); - // Search the coinstake transactions and abandon transactions that are not confirmed in the blocks - for (std::map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) - { - const CWalletTx* wtx = &(*it).second; - if (wtx && wtx->m_confirm.hashBlock.IsNull() && wtx->m_confirm.nIndex <= 0) - { - // Wallets need to refund inputs when disconnecting coinstake - const CTransaction& tx = *(wtx->tx); - if (tx.IsCoinStake() && IsFromMe(tx) && !wtx->isAbandoned()) - { - WalletLogPrintf("%s: Revert coinstake tx %s\n", __func__, wtx->GetHash().ToString()); - DisableTransaction(tx); - } - } - } -} -*/ - bool CWallet::MigrateToSQLite(bilingual_str& error) { AssertLockHeld(cs_wallet); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index c341796285..499376a8bb 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -304,8 +304,6 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati TxSpends mapTxSpends GUARDED_BY(cs_wallet); void AddToSpends(const COutPoint& outpoint, const uint256& wtxid, WalletBatch* batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); void AddToSpends(const CWalletTx& wtx, WalletBatch* batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); - void RemoveFromSpends(const COutPoint& outpoint, const uint256& wtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); - void RemoveFromSpends(const uint256& wtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); /** * Add a transaction to the wallet, or update it. confirm.block_* should @@ -758,12 +756,6 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati //! get the current wallet format (the oldest client version guaranteed to understand this wallet) int GetVersion() const { LOCK(cs_wallet); return nWalletVersion; } - // TEMP: Blackcoin ToDo: enable/disable! - /* - //! disable transaction for coinstake - void DisableTransaction(const CTransaction &tx); - */ - //! Get wallet transactions that conflict with given transaction (spend same outputs) std::set GetConflicts(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); @@ -974,12 +966,6 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati //! Add a descriptor to the wallet, return a ScriptPubKeyMan & associated output type ScriptPubKeyMan* AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); - // TEMP: Blackcoin ToDo: enable/disable! - /* - //! Clean coinstake transactions - void CleanCoinStake(); - */ - /** Move all records from the BDB database to a new SQLite database for storage. * The original BDB file will be deleted and replaced with a new SQLite file. * A backup is not created.