Rename ScanResult stop_block field
Avoid confusion with stop_block argument as suggested https://github.com/bitcoin/bitcoin/pull/14711#discussion_r252038449
This commit is contained in:
parent
2c0867a181
commit
95a812b599
5 changed files with 26 additions and 26 deletions
|
@ -149,8 +149,8 @@ void TestGUI()
|
||||||
reserver.reserve();
|
reserver.reserve();
|
||||||
CWallet::ScanResult result = wallet->ScanForWalletTransactions(locked_chain->getBlockHash(0), {} /* stop_block */, reserver, true /* fUpdate */);
|
CWallet::ScanResult result = wallet->ScanForWalletTransactions(locked_chain->getBlockHash(0), {} /* stop_block */, reserver, true /* fUpdate */);
|
||||||
QCOMPARE(result.status, CWallet::ScanResult::SUCCESS);
|
QCOMPARE(result.status, CWallet::ScanResult::SUCCESS);
|
||||||
QCOMPARE(result.stop_block, chainActive.Tip()->GetBlockHash());
|
QCOMPARE(result.last_scanned_block, chainActive.Tip()->GetBlockHash());
|
||||||
QVERIFY(result.failed_block.IsNull());
|
QVERIFY(result.last_failed_block.IsNull());
|
||||||
}
|
}
|
||||||
wallet->SetBroadcastTransactions(true);
|
wallet->SetBroadcastTransactions(true);
|
||||||
|
|
||||||
|
|
|
@ -3478,7 +3478,7 @@ UniValue rescanblockchain(const JSONRPCRequest& request)
|
||||||
}
|
}
|
||||||
UniValue response(UniValue::VOBJ);
|
UniValue response(UniValue::VOBJ);
|
||||||
response.pushKV("start_height", start_height);
|
response.pushKV("start_height", start_height);
|
||||||
response.pushKV("stop_height", result.stop_height ? *result.stop_height : UniValue());
|
response.pushKV("stop_height", result.last_scanned_height ? *result.last_scanned_height : UniValue());
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,9 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
|
||||||
reserver.reserve();
|
reserver.reserve();
|
||||||
CWallet::ScanResult result = wallet.ScanForWalletTransactions({} /* start_block */, {} /* stop_block */, reserver, false /* update */);
|
CWallet::ScanResult result = wallet.ScanForWalletTransactions({} /* start_block */, {} /* stop_block */, reserver, false /* update */);
|
||||||
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::SUCCESS);
|
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::SUCCESS);
|
||||||
BOOST_CHECK(result.failed_block.IsNull());
|
BOOST_CHECK(result.last_failed_block.IsNull());
|
||||||
BOOST_CHECK(result.stop_block.IsNull());
|
BOOST_CHECK(result.last_scanned_block.IsNull());
|
||||||
BOOST_CHECK(!result.stop_height);
|
BOOST_CHECK(!result.last_scanned_height);
|
||||||
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 0);
|
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,9 +69,9 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
|
||||||
reserver.reserve();
|
reserver.reserve();
|
||||||
CWallet::ScanResult result = wallet.ScanForWalletTransactions(oldTip->GetBlockHash(), {} /* stop_block */, reserver, false /* update */);
|
CWallet::ScanResult result = wallet.ScanForWalletTransactions(oldTip->GetBlockHash(), {} /* stop_block */, reserver, false /* update */);
|
||||||
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::SUCCESS);
|
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::SUCCESS);
|
||||||
BOOST_CHECK(result.failed_block.IsNull());
|
BOOST_CHECK(result.last_failed_block.IsNull());
|
||||||
BOOST_CHECK_EQUAL(result.stop_block, newTip->GetBlockHash());
|
BOOST_CHECK_EQUAL(result.last_scanned_block, newTip->GetBlockHash());
|
||||||
BOOST_CHECK_EQUAL(*result.stop_height, newTip->nHeight);
|
BOOST_CHECK_EQUAL(*result.last_scanned_height, newTip->nHeight);
|
||||||
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 100 * COIN);
|
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 100 * COIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,9 +88,9 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
|
||||||
reserver.reserve();
|
reserver.reserve();
|
||||||
CWallet::ScanResult result = wallet.ScanForWalletTransactions(oldTip->GetBlockHash(), {} /* stop_block */, reserver, false /* update */);
|
CWallet::ScanResult result = wallet.ScanForWalletTransactions(oldTip->GetBlockHash(), {} /* stop_block */, reserver, false /* update */);
|
||||||
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::FAILURE);
|
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::FAILURE);
|
||||||
BOOST_CHECK_EQUAL(result.failed_block, oldTip->GetBlockHash());
|
BOOST_CHECK_EQUAL(result.last_failed_block, oldTip->GetBlockHash());
|
||||||
BOOST_CHECK_EQUAL(result.stop_block, newTip->GetBlockHash());
|
BOOST_CHECK_EQUAL(result.last_scanned_block, newTip->GetBlockHash());
|
||||||
BOOST_CHECK_EQUAL(*result.stop_height, newTip->nHeight);
|
BOOST_CHECK_EQUAL(*result.last_scanned_height, newTip->nHeight);
|
||||||
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 50 * COIN);
|
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 50 * COIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,9 +106,9 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
|
||||||
reserver.reserve();
|
reserver.reserve();
|
||||||
CWallet::ScanResult result = wallet.ScanForWalletTransactions(oldTip->GetBlockHash(), {} /* stop_block */, reserver, false /* update */);
|
CWallet::ScanResult result = wallet.ScanForWalletTransactions(oldTip->GetBlockHash(), {} /* stop_block */, reserver, false /* update */);
|
||||||
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::FAILURE);
|
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::FAILURE);
|
||||||
BOOST_CHECK_EQUAL(result.failed_block, newTip->GetBlockHash());
|
BOOST_CHECK_EQUAL(result.last_failed_block, newTip->GetBlockHash());
|
||||||
BOOST_CHECK(result.stop_block.IsNull());
|
BOOST_CHECK(result.last_scanned_block.IsNull());
|
||||||
BOOST_CHECK(!result.stop_height);
|
BOOST_CHECK(!result.last_scanned_height);
|
||||||
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 0);
|
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,9 +345,9 @@ public:
|
||||||
reserver.reserve();
|
reserver.reserve();
|
||||||
CWallet::ScanResult result = wallet->ScanForWalletTransactions(chainActive.Genesis()->GetBlockHash(), {} /* stop_block */, reserver, false /* update */);
|
CWallet::ScanResult result = wallet->ScanForWalletTransactions(chainActive.Genesis()->GetBlockHash(), {} /* stop_block */, reserver, false /* update */);
|
||||||
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::SUCCESS);
|
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::SUCCESS);
|
||||||
BOOST_CHECK_EQUAL(result.stop_block, chainActive.Tip()->GetBlockHash());
|
BOOST_CHECK_EQUAL(result.last_scanned_block, chainActive.Tip()->GetBlockHash());
|
||||||
BOOST_CHECK_EQUAL(*result.stop_height, chainActive.Height());
|
BOOST_CHECK_EQUAL(*result.last_scanned_height, chainActive.Height());
|
||||||
BOOST_CHECK(result.failed_block.IsNull());
|
BOOST_CHECK(result.last_failed_block.IsNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
~ListCoinsTestingSetup()
|
~ListCoinsTestingSetup()
|
||||||
|
|
|
@ -1603,7 +1603,7 @@ int64_t CWallet::RescanFromTime(int64_t startTime, const WalletRescanReserver& r
|
||||||
ScanResult result = ScanForWalletTransactions(start_block, {} /* stop_block */, reserver, update);
|
ScanResult result = ScanForWalletTransactions(start_block, {} /* stop_block */, reserver, update);
|
||||||
if (result.status == ScanResult::FAILURE) {
|
if (result.status == ScanResult::FAILURE) {
|
||||||
int64_t time_max;
|
int64_t time_max;
|
||||||
if (!chain().findBlock(result.failed_block, nullptr /* block */, nullptr /* time */, &time_max)) {
|
if (!chain().findBlock(result.last_failed_block, nullptr /* block */, nullptr /* time */, &time_max)) {
|
||||||
throw std::logic_error("ScanForWalletTransactions returned invalid block hash");
|
throw std::logic_error("ScanForWalletTransactions returned invalid block hash");
|
||||||
}
|
}
|
||||||
return time_max + TIMESTAMP_WINDOW + 1;
|
return time_max + TIMESTAMP_WINDOW + 1;
|
||||||
|
@ -1678,7 +1678,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
|
||||||
// marking transactions as coming from the wrong block.
|
// marking transactions as coming from the wrong block.
|
||||||
// TODO: This should return success instead of failure, see
|
// TODO: This should return success instead of failure, see
|
||||||
// https://github.com/bitcoin/bitcoin/pull/14711#issuecomment-458342518
|
// https://github.com/bitcoin/bitcoin/pull/14711#issuecomment-458342518
|
||||||
result.failed_block = block_hash;
|
result.last_failed_block = block_hash;
|
||||||
result.status = ScanResult::FAILURE;
|
result.status = ScanResult::FAILURE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1686,11 +1686,11 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
|
||||||
SyncTransaction(block.vtx[posInBlock], block_hash, posInBlock, fUpdate);
|
SyncTransaction(block.vtx[posInBlock], block_hash, posInBlock, fUpdate);
|
||||||
}
|
}
|
||||||
// scan succeeded, record block as most recent successfully scanned
|
// scan succeeded, record block as most recent successfully scanned
|
||||||
result.stop_block = block_hash;
|
result.last_scanned_block = block_hash;
|
||||||
result.stop_height = *block_height;
|
result.last_scanned_height = *block_height;
|
||||||
} else {
|
} else {
|
||||||
// could not scan block, keep scanning but record this block as the most recent failure
|
// could not scan block, keep scanning but record this block as the most recent failure
|
||||||
result.failed_block = block_hash;
|
result.last_failed_block = block_hash;
|
||||||
result.status = ScanResult::FAILURE;
|
result.status = ScanResult::FAILURE;
|
||||||
}
|
}
|
||||||
if (block_hash == stop_block) {
|
if (block_hash == stop_block) {
|
||||||
|
|
|
@ -912,14 +912,14 @@ public:
|
||||||
//! Hash and height of most recent block that was successfully scanned.
|
//! Hash and height of most recent block that was successfully scanned.
|
||||||
//! Unset if no blocks were scanned due to read errors or the chain
|
//! Unset if no blocks were scanned due to read errors or the chain
|
||||||
//! being empty.
|
//! being empty.
|
||||||
uint256 stop_block;
|
uint256 last_scanned_block;
|
||||||
Optional<int> stop_height;
|
Optional<int> last_scanned_height;
|
||||||
|
|
||||||
//! Height of the most recent block that could not be scanned due to
|
//! Height of the most recent block that could not be scanned due to
|
||||||
//! read errors or pruning. Will be set if status is FAILURE, unset if
|
//! read errors or pruning. Will be set if status is FAILURE, unset if
|
||||||
//! status is SUCCESS, and may or may not be set if status is
|
//! status is SUCCESS, and may or may not be set if status is
|
||||||
//! USER_ABORT.
|
//! USER_ABORT.
|
||||||
uint256 failed_block;
|
uint256 last_failed_block;
|
||||||
};
|
};
|
||||||
ScanResult ScanForWalletTransactions(const uint256& first_block, const uint256& last_block, const WalletRescanReserver& reserver, bool fUpdate);
|
ScanResult ScanForWalletTransactions(const uint256& first_block, const uint256& last_block, const WalletRescanReserver& reserver, bool fUpdate);
|
||||||
void TransactionRemovedFromMempool(const CTransactionRef &ptx) override;
|
void TransactionRemovedFromMempool(const CTransactionRef &ptx) override;
|
||||||
|
|
Loading…
Reference in a new issue