Skip to content

Commit 95a812b

Browse files
committed
Rename ScanResult stop_block field
Avoid confusion with stop_block argument as suggested bitcoin/bitcoin#14711 (comment)
1 parent 2c0867a commit 95a812b

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

src/qt/test/wallettests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ void TestGUI()
149149
reserver.reserve();
150150
CWallet::ScanResult result = wallet->ScanForWalletTransactions(locked_chain->getBlockHash(0), {} /* stop_block */, reserver, true /* fUpdate */);
151151
QCOMPARE(result.status, CWallet::ScanResult::SUCCESS);
152-
QCOMPARE(result.stop_block, chainActive.Tip()->GetBlockHash());
153-
QVERIFY(result.failed_block.IsNull());
152+
QCOMPARE(result.last_scanned_block, chainActive.Tip()->GetBlockHash());
153+
QVERIFY(result.last_failed_block.IsNull());
154154
}
155155
wallet->SetBroadcastTransactions(true);
156156

src/wallet/rpcwallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3478,7 +3478,7 @@ UniValue rescanblockchain(const JSONRPCRequest& request)
34783478
}
34793479
UniValue response(UniValue::VOBJ);
34803480
response.pushKV("start_height", start_height);
3481-
response.pushKV("stop_height", result.stop_height ? *result.stop_height : UniValue());
3481+
response.pushKV("stop_height", result.last_scanned_height ? *result.last_scanned_height : UniValue());
34823482
return response;
34833483
}
34843484

src/wallet/test/wallet_tests.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
5454
reserver.reserve();
5555
CWallet::ScanResult result = wallet.ScanForWalletTransactions({} /* start_block */, {} /* stop_block */, reserver, false /* update */);
5656
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::SUCCESS);
57-
BOOST_CHECK(result.failed_block.IsNull());
58-
BOOST_CHECK(result.stop_block.IsNull());
59-
BOOST_CHECK(!result.stop_height);
57+
BOOST_CHECK(result.last_failed_block.IsNull());
58+
BOOST_CHECK(result.last_scanned_block.IsNull());
59+
BOOST_CHECK(!result.last_scanned_height);
6060
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 0);
6161
}
6262

@@ -69,9 +69,9 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
6969
reserver.reserve();
7070
CWallet::ScanResult result = wallet.ScanForWalletTransactions(oldTip->GetBlockHash(), {} /* stop_block */, reserver, false /* update */);
7171
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::SUCCESS);
72-
BOOST_CHECK(result.failed_block.IsNull());
73-
BOOST_CHECK_EQUAL(result.stop_block, newTip->GetBlockHash());
74-
BOOST_CHECK_EQUAL(*result.stop_height, newTip->nHeight);
72+
BOOST_CHECK(result.last_failed_block.IsNull());
73+
BOOST_CHECK_EQUAL(result.last_scanned_block, newTip->GetBlockHash());
74+
BOOST_CHECK_EQUAL(*result.last_scanned_height, newTip->nHeight);
7575
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 100 * COIN);
7676
}
7777

@@ -88,9 +88,9 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
8888
reserver.reserve();
8989
CWallet::ScanResult result = wallet.ScanForWalletTransactions(oldTip->GetBlockHash(), {} /* stop_block */, reserver, false /* update */);
9090
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::FAILURE);
91-
BOOST_CHECK_EQUAL(result.failed_block, oldTip->GetBlockHash());
92-
BOOST_CHECK_EQUAL(result.stop_block, newTip->GetBlockHash());
93-
BOOST_CHECK_EQUAL(*result.stop_height, newTip->nHeight);
91+
BOOST_CHECK_EQUAL(result.last_failed_block, oldTip->GetBlockHash());
92+
BOOST_CHECK_EQUAL(result.last_scanned_block, newTip->GetBlockHash());
93+
BOOST_CHECK_EQUAL(*result.last_scanned_height, newTip->nHeight);
9494
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 50 * COIN);
9595
}
9696

@@ -106,9 +106,9 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
106106
reserver.reserve();
107107
CWallet::ScanResult result = wallet.ScanForWalletTransactions(oldTip->GetBlockHash(), {} /* stop_block */, reserver, false /* update */);
108108
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::FAILURE);
109-
BOOST_CHECK_EQUAL(result.failed_block, newTip->GetBlockHash());
110-
BOOST_CHECK(result.stop_block.IsNull());
111-
BOOST_CHECK(!result.stop_height);
109+
BOOST_CHECK_EQUAL(result.last_failed_block, newTip->GetBlockHash());
110+
BOOST_CHECK(result.last_scanned_block.IsNull());
111+
BOOST_CHECK(!result.last_scanned_height);
112112
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 0);
113113
}
114114
}
@@ -345,9 +345,9 @@ class ListCoinsTestingSetup : public TestChain100Setup
345345
reserver.reserve();
346346
CWallet::ScanResult result = wallet->ScanForWalletTransactions(chainActive.Genesis()->GetBlockHash(), {} /* stop_block */, reserver, false /* update */);
347347
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::SUCCESS);
348-
BOOST_CHECK_EQUAL(result.stop_block, chainActive.Tip()->GetBlockHash());
349-
BOOST_CHECK_EQUAL(*result.stop_height, chainActive.Height());
350-
BOOST_CHECK(result.failed_block.IsNull());
348+
BOOST_CHECK_EQUAL(result.last_scanned_block, chainActive.Tip()->GetBlockHash());
349+
BOOST_CHECK_EQUAL(*result.last_scanned_height, chainActive.Height());
350+
BOOST_CHECK(result.last_failed_block.IsNull());
351351
}
352352

353353
~ListCoinsTestingSetup()

src/wallet/wallet.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,7 @@ int64_t CWallet::RescanFromTime(int64_t startTime, const WalletRescanReserver& r
16031603
ScanResult result = ScanForWalletTransactions(start_block, {} /* stop_block */, reserver, update);
16041604
if (result.status == ScanResult::FAILURE) {
16051605
int64_t time_max;
1606-
if (!chain().findBlock(result.failed_block, nullptr /* block */, nullptr /* time */, &time_max)) {
1606+
if (!chain().findBlock(result.last_failed_block, nullptr /* block */, nullptr /* time */, &time_max)) {
16071607
throw std::logic_error("ScanForWalletTransactions returned invalid block hash");
16081608
}
16091609
return time_max + TIMESTAMP_WINDOW + 1;
@@ -1678,19 +1678,19 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
16781678
// marking transactions as coming from the wrong block.
16791679
// TODO: This should return success instead of failure, see
16801680
// https://github.com/bitcoin/bitcoin/pull/14711#issuecomment-458342518
1681-
result.failed_block = block_hash;
1681+
result.last_failed_block = block_hash;
16821682
result.status = ScanResult::FAILURE;
16831683
break;
16841684
}
16851685
for (size_t posInBlock = 0; posInBlock < block.vtx.size(); ++posInBlock) {
16861686
SyncTransaction(block.vtx[posInBlock], block_hash, posInBlock, fUpdate);
16871687
}
16881688
// scan succeeded, record block as most recent successfully scanned
1689-
result.stop_block = block_hash;
1690-
result.stop_height = *block_height;
1689+
result.last_scanned_block = block_hash;
1690+
result.last_scanned_height = *block_height;
16911691
} else {
16921692
// could not scan block, keep scanning but record this block as the most recent failure
1693-
result.failed_block = block_hash;
1693+
result.last_failed_block = block_hash;
16941694
result.status = ScanResult::FAILURE;
16951695
}
16961696
if (block_hash == stop_block) {

src/wallet/wallet.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -912,14 +912,14 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
912912
//! Hash and height of most recent block that was successfully scanned.
913913
//! Unset if no blocks were scanned due to read errors or the chain
914914
//! being empty.
915-
uint256 stop_block;
916-
Optional<int> stop_height;
915+
uint256 last_scanned_block;
916+
Optional<int> last_scanned_height;
917917

918918
//! Height of the most recent block that could not be scanned due to
919919
//! read errors or pruning. Will be set if status is FAILURE, unset if
920920
//! status is SUCCESS, and may or may not be set if status is
921921
//! USER_ABORT.
922-
uint256 failed_block;
922+
uint256 last_failed_block;
923923
};
924924
ScanResult ScanForWalletTransactions(const uint256& first_block, const uint256& last_block, const WalletRescanReserver& reserver, bool fUpdate);
925925
void TransactionRemovedFromMempool(const CTransactionRef &ptx) override;

0 commit comments

Comments
 (0)