diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1690,12 +1690,8 @@ // iterate backwards until we have nCount items to return: for (CWallet::TxItems::const_reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) { - CWalletTx *const pwtx = (*it).second.first; - if (pwtx != nullptr) { - ListTransactions(*locked_chain, pwallet, *pwtx, 0, true, ret, - filter); - } - + CWalletTx *const pwtx = (*it).second; + ListTransactions(*locked_chain, pwallet, *pwtx, 0, true, ret, filter); if ((int)ret.size() >= (nCount + nFrom)) { break; } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -394,9 +394,7 @@ std::string strFromAccount; //! position in ordered transaction list int64_t nOrderPos; - std::multimap>::const_iterator - m_it_wtxOrdered; + std::multimap::const_iterator m_it_wtxOrdered; // memory only mutable bool fDebitCached; @@ -658,86 +656,6 @@ } }; -/** - * DEPRECATED Internal transfers. - * Database key is acentry. - */ -class CAccountingEntry { -public: - std::string strAccount; - Amount nCreditDebit; - int64_t nTime; - std::string strOtherAccount; - std::string strComment; - mapValue_t mapValue; - //! position in ordered transaction list - int64_t nOrderPos; - uint64_t nEntryNo; - - CAccountingEntry() { SetNull(); } - - void SetNull() { - nCreditDebit = Amount::zero(); - nTime = 0; - strAccount.clear(); - strOtherAccount.clear(); - strComment.clear(); - nOrderPos = -1; - nEntryNo = 0; - } - - template void Serialize(Stream &s) const { - int nVersion = s.GetVersion(); - if (!(s.GetType() & SER_GETHASH)) { - s << nVersion; - } - //! Note: strAccount is serialized as part of the key, not here. - s << nCreditDebit << nTime << strOtherAccount; - - mapValue_t mapValueCopy = mapValue; - WriteOrderPos(nOrderPos, mapValueCopy); - - std::string strCommentCopy = strComment; - if (!mapValueCopy.empty() || !_ssExtra.empty()) { - CDataStream ss(s.GetType(), s.GetVersion()); - ss.insert(ss.begin(), '\0'); - ss << mapValueCopy; - ss.insert(ss.end(), _ssExtra.begin(), _ssExtra.end()); - strCommentCopy.append(ss.str()); - } - s << strCommentCopy; - } - - template void Unserialize(Stream &s) { - int nVersion = s.GetVersion(); - if (!(s.GetType() & SER_GETHASH)) { - s >> nVersion; - } - //! Note: strAccount is serialized as part of the key, not here. - s >> nCreditDebit >> nTime >> LIMITED_STRING(strOtherAccount, 65536) >> - LIMITED_STRING(strComment, 65536); - - size_t nSepPos = strComment.find('\0'); - mapValue.clear(); - if (std::string::npos != nSepPos) { - CDataStream ss(std::vector(strComment.begin() + nSepPos + 1, - strComment.end()), - s.GetType(), s.GetVersion()); - ss >> mapValue; - _ssExtra = std::vector(ss.begin(), ss.end()); - } - ReadOrderPos(nOrderPos, mapValue); - if (std::string::npos != nSepPos) { - strComment.erase(nSepPos); - } - - mapValue.erase("n"); - } - -private: - std::vector _ssExtra; -}; - struct CoinSelectionParams { bool use_bnb = true; size_t change_output_size = 0; @@ -956,10 +874,8 @@ } std::map mapWallet GUARDED_BY(cs_wallet); - std::list laccentries; - typedef std::pair TxPair; - typedef std::multimap TxItems; + typedef std::multimap TxItems; TxItems wtxOrdered; int64_t nOrderPosNext GUARDED_BY(cs_wallet) = 0; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -881,26 +881,21 @@ for (auto &entry : mapWallet) { CWalletTx *wtx = &entry.second; - txByTime.insert( - std::make_pair(wtx->nTimeReceived, TxPair(wtx, nullptr))); + txByTime.insert(std::make_pair(wtx->nTimeReceived, wtx)); } nOrderPosNext = 0; std::vector nOrderPosOffsets; for (TxItems::iterator it = txByTime.begin(); it != txByTime.end(); ++it) { - CWalletTx *const pwtx = (*it).second.first; - CAccountingEntry *const pacentry = (*it).second.second; - int64_t &nOrderPos = - (pwtx != nullptr) ? pwtx->nOrderPos : pacentry->nOrderPos; + CWalletTx *const pwtx = (*it).second; + int64_t &nOrderPos = pwtx->nOrderPos; if (nOrderPos == -1) { nOrderPos = nOrderPosNext++; nOrderPosOffsets.push_back(nOrderPos); - if (pwtx) { - if (!batch.WriteTx(*pwtx)) { - return DBErrors::LOAD_FAIL; - } + if (!batch.WriteTx(*pwtx)) { + return DBErrors::LOAD_FAIL; } } else { int64_t nOrderPosOff = 0; @@ -918,10 +913,8 @@ } // Since we're changing the order, write it back. - if (pwtx) { - if (!batch.WriteTx(*pwtx)) { - return DBErrors::LOAD_FAIL; - } + if (!batch.WriteTx(*pwtx)) { + return DBErrors::LOAD_FAIL; } } } @@ -1011,8 +1004,8 @@ if (fInsertedNew) { wtx.nTimeReceived = GetAdjustedTime(); wtx.nOrderPos = IncOrderPosNext(&batch); - wtx.m_it_wtxOrdered = wtxOrdered.insert( - std::make_pair(wtx.nOrderPos, TxPair(&wtx, nullptr))); + wtx.m_it_wtxOrdered = + wtxOrdered.insert(std::make_pair(wtx.nOrderPos, &wtx)); wtx.nTimeSmart = ComputeTimeSmart(wtx); AddToSpends(txid); } @@ -1077,8 +1070,8 @@ CWalletTx &wtx = ins.first->second; wtx.BindWallet(this); if (/* insertion took place */ ins.second) { - wtx.m_it_wtxOrdered = wtxOrdered.insert( - std::make_pair(wtx.nOrderPos, TxPair(&wtx, nullptr))); + wtx.m_it_wtxOrdered = + wtxOrdered.insert(std::make_pair(wtx.nOrderPos, &wtx)); } AddToSpends(txid); for (const CTxIn &txin : wtx.tx->vin) { @@ -4277,19 +4270,14 @@ int64_t latestTolerated = latestNow + 300; const TxItems &txOrdered = wtxOrdered; for (auto it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) { - CWalletTx *const pwtx = it->second.first; + CWalletTx *const pwtx = it->second; if (pwtx == &wtx) { continue; } - CAccountingEntry *const pacentry = it->second.second; int64_t nSmartTime; - if (pwtx) { - nSmartTime = pwtx->nTimeSmart; - if (!nSmartTime) { - nSmartTime = pwtx->nTimeReceived; - } - } else { - nSmartTime = pacentry->nTime; + nSmartTime = pwtx->nTimeSmart; + if (!nSmartTime) { + nSmartTime = pwtx->nTimeReceived; } if (nSmartTime <= latestTolerated) { latestEntry = nSmartTime; diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -35,7 +35,6 @@ static const bool DEFAULT_FLUSHWALLET = true; class CAccount; -class CAccountingEntry; struct CBlockLocator; class CKeyPool; class CMasterKey;