@@ -1613,9 +1613,9 @@ int64_t CWallet::RescanFromTime(int64_t startTime, const WalletRescanReserver& r
1613
1613
}
1614
1614
1615
1615
if (startBlock) {
1616
- const CBlockIndex* failedBlock;
1616
+ const CBlockIndex * failedBlock, *stop_block ;
1617
1617
// TODO: this should take into account failure by ScanResult::USER_ABORT
1618
- if (ScanResult::FAILURE == ScanForWalletTransactions (startBlock, nullptr , reserver, failedBlock, update)) {
1618
+ if (ScanResult::FAILURE == ScanForWalletTransactions (startBlock, nullptr , reserver, failedBlock, stop_block, update)) {
1619
1619
return failedBlock->GetBlockTimeMax () + TIMESTAMP_WINDOW + 1 ;
1620
1620
}
1621
1621
}
@@ -1628,8 +1628,10 @@ int64_t CWallet::RescanFromTime(int64_t startTime, const WalletRescanReserver& r
1628
1628
* exist in the wallet will be updated.
1629
1629
*
1630
1630
* @param[in] pindexStop if not a nullptr, the scan will stop at this block-index
1631
- * @param[out] failed_block if FAILURE is returned, will be set to the most
1632
- * recent block that could not be scanned, otherwise nullptr
1631
+ * @param[out] failed_block if FAILURE is returned, the most recent block
1632
+ * that could not be scanned, otherwise nullptr
1633
+ * @param[out] stop_block the most recent block that could be scanned,
1634
+ * otherwise nullptr if no block could be scanned
1633
1635
*
1634
1636
* @return ScanResult indicating success or failure of the scan. SUCCESS if
1635
1637
* scan was successful. FAILURE if a complete rescan was not possible (due to
@@ -1640,7 +1642,7 @@ int64_t CWallet::RescanFromTime(int64_t startTime, const WalletRescanReserver& r
1640
1642
* the main chain after to the addition of any new keys you want to detect
1641
1643
* transactions for.
1642
1644
*/
1643
- CWallet::ScanResult CWallet::ScanForWalletTransactions (const CBlockIndex* const pindexStart, const CBlockIndex* const pindexStop, const WalletRescanReserver& reserver, const CBlockIndex*& failed_block, bool fUpdate )
1645
+ CWallet::ScanResult CWallet::ScanForWalletTransactions (const CBlockIndex* const pindexStart, const CBlockIndex* const pindexStop, const WalletRescanReserver& reserver, const CBlockIndex*& failed_block, const CBlockIndex*& stop_block, bool fUpdate )
1644
1646
{
1645
1647
int64_t nNow = GetTime ();
1646
1648
const CChainParams& chainParams = Params ();
@@ -1694,7 +1696,10 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const CBlockIndex* const
1694
1696
for (size_t posInBlock = 0 ; posInBlock < block.vtx .size (); ++posInBlock) {
1695
1697
SyncTransaction (block.vtx [posInBlock], pindex, posInBlock, fUpdate );
1696
1698
}
1699
+ // scan succeeded, record block as most recent successfully scanned
1700
+ stop_block = pindex;
1697
1701
} else {
1702
+ // could not scan block, keep scanning but record this block as the most recent failure
1698
1703
failed_block = pindex;
1699
1704
}
1700
1705
if (pindex == pindexStop) {
@@ -4174,8 +4179,8 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
4174
4179
nStart = GetTimeMillis ();
4175
4180
{
4176
4181
WalletRescanReserver reserver (walletInstance.get ());
4177
- const CBlockIndex* stop_block;
4178
- if (!reserver.reserve () || (ScanResult::SUCCESS != walletInstance->ScanForWalletTransactions (pindexRescan, nullptr , reserver, stop_block, true ))) {
4182
+ const CBlockIndex * stop_block, *failed_block ;
4183
+ if (!reserver.reserve () || (ScanResult::SUCCESS != walletInstance->ScanForWalletTransactions (pindexRescan, nullptr , reserver, failed_block, stop_block, true ))) {
4179
4184
InitError (_ (" Failed to rescan the wallet during initialization" ));
4180
4185
return nullptr ;
4181
4186
}
0 commit comments