Make wallet descendant searching more efficient

pull/262/head
Alex Morcos 9 years ago
parent f61766b37b
commit 9e69717254

@ -784,14 +784,14 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
// Do not flush the wallet here for performance reasons // Do not flush the wallet here for performance reasons
CWalletDB walletdb(strWalletFile, "r+", false); CWalletDB walletdb(strWalletFile, "r+", false);
std::deque<uint256> todo; std::set<uint256> todo;
std::set<uint256> done; std::set<uint256> done;
todo.push_back(hashTx); todo.insert(hashTx);
while (!todo.empty()) { while (!todo.empty()) {
uint256 now = todo.front(); uint256 now = *todo.begin();
todo.pop_front(); todo.erase(now);
done.insert(now); done.insert(now);
assert(mapWallet.count(now)); assert(mapWallet.count(now));
CWalletTx& wtx = mapWallet[now]; CWalletTx& wtx = mapWallet[now];
@ -807,7 +807,7 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
TxSpends::const_iterator iter = mapTxSpends.lower_bound(COutPoint(now, 0)); TxSpends::const_iterator iter = mapTxSpends.lower_bound(COutPoint(now, 0));
while (iter != mapTxSpends.end() && iter->first.hash == now) { while (iter != mapTxSpends.end() && iter->first.hash == now) {
if (!done.count(iter->second)) { if (!done.count(iter->second)) {
todo.push_back(iter->second); todo.insert(iter->second);
} }
iter++; iter++;
} }

Loading…
Cancel
Save