| 588 | } |
| 589 | |
| 590 | void CWallet::SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator> range) |
| 591 | { |
| 592 | // We want all the wallet transactions in range to have the same metadata as |
| 593 | // the oldest (smallest nOrderPos). |
| 594 | // So: find smallest nOrderPos: |
| 595 | |
| 596 | int nMinOrderPos = std::numeric_limits<int>::max(); |
| 597 | const CWalletTx* copyFrom = nullptr; |
| 598 | for (TxSpends::iterator it = range.first; it != range.second; ++it) { |
| 599 | const CWalletTx* wtx = &mapWallet.at(it->second); |
| 600 | if (wtx->nOrderPos < nMinOrderPos) { |
| 601 | nMinOrderPos = wtx->nOrderPos; |
| 602 | copyFrom = wtx; |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | if (!copyFrom) { |
| 607 | return; |
| 608 | } |
| 609 | |
| 610 | // Now copy data from copyFrom to rest: |
| 611 | for (TxSpends::iterator it = range.first; it != range.second; ++it) |
| 612 | { |
| 613 | const uint256& hash = it->second; |
| 614 | CWalletTx* copyTo = &mapWallet.at(hash); |
| 615 | if (copyFrom == copyTo) continue; |
| 616 | assert(copyFrom && "Oldest wallet transaction in range assumed to have been found."); |
| 617 | if (!copyFrom->IsEquivalentTo(*copyTo)) continue; |
| 618 | copyTo->mapValue = copyFrom->mapValue; |
| 619 | copyTo->vOrderForm = copyFrom->vOrderForm; |
| 620 | // fTimeReceivedIsTxTime not copied on purpose |
| 621 | // nTimeReceived not copied on purpose |
| 622 | copyTo->nTimeSmart = copyFrom->nTimeSmart; |
| 623 | copyTo->fFromMe = copyFrom->fFromMe; |
| 624 | // nOrderPos not copied on purpose |
| 625 | // cached members not copied on purpose |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | /** |
| 630 | * Outpoint is spent if any non-conflicted transaction |
nothing calls this directly
no test coverage detected