[wallet] Remove duplicate mapWallet lookups
This commit is contained in:
parent
2ae7cf8ef5
commit
039425cf4f
1 changed files with 6 additions and 11 deletions
|
@ -531,14 +531,11 @@ void CWallet::SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator> ran
|
||||||
|
|
||||||
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 CWalletTx* wtx = &mapWallet[it->second];
|
||||||
const uint256& hash = it->second;
|
if (wtx->nOrderPos < nMinOrderPos) {
|
||||||
int n = mapWallet[hash].nOrderPos;
|
nMinOrderPos = wtx->nOrderPos;;
|
||||||
if (n < nMinOrderPos)
|
copyFrom = wtx;
|
||||||
{
|
|
||||||
nMinOrderPos = n;
|
|
||||||
copyFrom = &mapWallet[hash];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -988,9 +985,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
|
||||||
bool CWallet::LoadToWallet(const CWalletTx& wtxIn)
|
bool CWallet::LoadToWallet(const CWalletTx& wtxIn)
|
||||||
{
|
{
|
||||||
uint256 hash = wtxIn.GetHash();
|
uint256 hash = wtxIn.GetHash();
|
||||||
|
CWalletTx& wtx = mapWallet.emplace(hash, wtxIn).first->second;
|
||||||
mapWallet[hash] = wtxIn;
|
|
||||||
CWalletTx& wtx = mapWallet[hash];
|
|
||||||
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(hash);
|
AddToSpends(hash);
|
||||||
|
|
Loading…
Reference in a new issue