Skip to content

Commit

Permalink
cleanup: Remove unused CleanCoinStake() and related functions
Browse files Browse the repository at this point in the history
  • Loading branch information
lateminer committed Jan 18, 2024
1 parent dbc0c91 commit 0207160
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 126 deletions.
10 changes: 0 additions & 10 deletions src/node/blockstorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,16 +730,6 @@ void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> 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<CWallet>& pwallet : GetWallets()) {
pwallet->CleanCoinStake();
}
#endif
*/
}

// -loadblock=
Expand Down
102 changes: 0 additions & 102 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TxSpends::iterator, TxSpends::iterator> 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!
Expand All @@ -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())
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -2630,35 +2587,6 @@ std::vector<CTxDestination> CWallet::ListAddrBookAddresses(const std::optional<A
return result;
}

/*
// TEMP: Blackcoin ToDo: enable/disable!
// disable transaction (only for coinstake)
void CWallet::DisableTransaction(const CTransaction &tx)
{
if (!tx.IsCoinStake() || !IsFromMe(tx))
return; // only disconnecting coinstake requires marking input unspent
uint256 hash = tx.GetHash();
if (AbandonTransaction(hash))
{
LOCK(cs_wallet);
RemoveFromSpends(hash);
for (const CTxIn& txin : tx.vin)
{
auto it = mapWallet.find(txin.prevout.hash);
if (it != mapWallet.end()) {
CWalletTx &coin = it->second;
coin.MarkDirty();
NotifyTransactionChanged(coin.GetHash(), CT_UPDATED);
}
}
CWalletTx& wtx = mapWallet.at(hash);
wtx.MarkDirty();
NotifyTransactionChanged(hash, CT_DELETED);
}
}
*/

std::set<std::string> CWallet::ListAddrBookLabels(const std::optional<AddressPurpose> purpose) const
{
AssertLockHeld(cs_wallet);
Expand Down Expand Up @@ -3226,13 +3154,6 @@ std::shared_ptr<CWallet> 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();

Expand Down Expand Up @@ -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<uint256, CWalletTx>::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);
Expand Down
14 changes: 0 additions & 14 deletions src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<uint256> GetConflicts(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 0207160

Please sign in to comment.