Refactor: Move nTimeFirstKey accesses out of CWallet

This commit does not change behavior.
This commit is contained in:
Andrew Chow
2019-10-07 14:11:34 -04:00
parent 7ef47b88e6
commit 152b0a00d8
4 changed files with 17 additions and 3 deletions

View File

@@ -3804,8 +3804,13 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
// No need to read and scan block if block was created before
// our wallet birthday (as adjusted for block time variability)
if (walletInstance->nTimeFirstKey) {
if (Optional<int> first_block = locked_chain->findFirstBlockWithTimeAndHeight(walletInstance->nTimeFirstKey - TIMESTAMP_WINDOW, rescan_height, nullptr)) {
Optional<int64_t> time_first_key;
if (auto spk_man = walletInstance->m_spk_man.get()) {
int64_t time = spk_man->GetTimeFirstKey();
if (!time_first_key || time < *time_first_key) time_first_key = time;
}
if (time_first_key) {
if (Optional<int> first_block = locked_chain->findFirstBlockWithTimeAndHeight(*time_first_key - TIMESTAMP_WINDOW, rescan_height, nullptr)) {
rescan_height = *first_block;
}
}