Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 574 Lines • ▼ Show 20 Lines | void CWallet::SyncMetaData( | ||||
std::pair<TxSpends::iterator, TxSpends::iterator> range) { | std::pair<TxSpends::iterator, TxSpends::iterator> range) { | ||||
// We want all the wallet transactions in range to have the same metadata as | // We want all the wallet transactions in range to have the same metadata as | ||||
// the oldest (smallest nOrderPos). | // the oldest (smallest nOrderPos). | ||||
// So: find smallest nOrderPos: | // So: find smallest nOrderPos: | ||||
int nMinOrderPos = std::numeric_limits<int>::max(); | int nMinOrderPos = std::numeric_limits<int>::max(); | ||||
const CWalletTx *copyFrom = nullptr; | const CWalletTx *copyFrom = nullptr; | ||||
for (TxSpends::iterator it = range.first; it != range.second; ++it) { | for (TxSpends::iterator it = range.first; it != range.second; ++it) { | ||||
const TxId &txid = it->second; | const CWalletTx *wtx = &mapWallet[it->second]; | ||||
int n = mapWallet[txid].nOrderPos; | if (wtx->nOrderPos < nMinOrderPos) { | ||||
if (n < nMinOrderPos) { | nMinOrderPos = wtx->nOrderPos; | ||||
nMinOrderPos = n; | copyFrom = wtx; | ||||
copyFrom = &mapWallet[txid]; | |||||
} | } | ||||
} | } | ||||
// Now copy data from copyFrom to rest: | // Now copy data from copyFrom to rest: | ||||
for (TxSpends::iterator it = range.first; it != range.second; ++it) { | for (TxSpends::iterator it = range.first; it != range.second; ++it) { | ||||
const TxId &txid = it->second; | const TxId &txid = it->second; | ||||
CWalletTx *copyTo = &mapWallet[txid]; | CWalletTx *copyTo = &mapWallet[txid]; | ||||
if (copyFrom == copyTo) { | if (copyFrom == copyTo) { | ||||
▲ Show 20 Lines • Show All 410 Lines • ▼ Show 20 Lines | if (!strCmd.empty()) { | ||||
t.detach(); | t.detach(); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool CWallet::LoadToWallet(const CWalletTx &wtxIn) { | bool CWallet::LoadToWallet(const CWalletTx &wtxIn) { | ||||
const TxId &txid = wtxIn.GetId(); | const TxId &txid = wtxIn.GetId(); | ||||
CWalletTx &wtx = mapWallet.emplace(txid, wtxIn).first->second; | |||||
mapWallet[txid] = wtxIn; | |||||
CWalletTx &wtx = mapWallet[txid]; | |||||
wtx.BindWallet(this); | wtx.BindWallet(this); | ||||
wtxOrdered.insert(std::make_pair(wtx.nOrderPos, TxPair(&wtx, nullptr))); | wtxOrdered.insert(std::make_pair(wtx.nOrderPos, TxPair(&wtx, nullptr))); | ||||
AddToSpends(txid); | AddToSpends(txid); | ||||
for (const CTxIn &txin : wtx.tx->vin) { | for (const CTxIn &txin : wtx.tx->vin) { | ||||
if (mapWallet.count(txin.prevout.GetTxId())) { | if (mapWallet.count(txin.prevout.GetTxId())) { | ||||
CWalletTx &prevtx = mapWallet[txin.prevout.GetTxId()]; | CWalletTx &prevtx = mapWallet[txin.prevout.GetTxId()]; | ||||
if (prevtx.nIndex == -1 && !prevtx.hashUnset()) { | if (prevtx.nIndex == -1 && !prevtx.hashUnset()) { | ||||
MarkConflicted(prevtx.hashBlock, wtx.GetId()); | MarkConflicted(prevtx.hashBlock, wtx.GetId()); | ||||
▲ Show 20 Lines • Show All 3,295 Lines • Show Last 20 Lines |