mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-19 12:10:19 +01:00
Dedup nTimeFirstKey update logic
Also make nTimeFirstKey member variable private. This is just a cleanup change, it doesn't change behavior in any significant way.
This commit is contained in:
@@ -143,7 +143,7 @@ UniValue importprivkey(const JSONRPCRequest& request)
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet");
|
||||
|
||||
// whenever a key is imported, we need to scan the whole chain
|
||||
pwalletMain->nTimeFirstKey = 1; // 0 would be considered 'no value'
|
||||
pwalletMain->UpdateTimeFirstKey(1);
|
||||
|
||||
if (fRescan) {
|
||||
pwalletMain->ScanForWalletTransactions(chainActive.Genesis(), true);
|
||||
@@ -500,8 +500,7 @@ UniValue importwallet(const JSONRPCRequest& request)
|
||||
while (pindex && pindex->pprev && pindex->GetBlockTime() > nTimeBegin - 7200)
|
||||
pindex = pindex->pprev;
|
||||
|
||||
if (!pwalletMain->nTimeFirstKey || nTimeBegin < pwalletMain->nTimeFirstKey)
|
||||
pwalletMain->nTimeFirstKey = nTimeBegin;
|
||||
pwalletMain->UpdateTimeFirstKey(nTimeBegin);
|
||||
|
||||
LogPrintf("Rescanning last %i blocks\n", chainActive.Height() - pindex->nHeight + 1);
|
||||
pwalletMain->ScanForWalletTransactions(pindex);
|
||||
@@ -782,9 +781,7 @@ UniValue ProcessImport(const UniValue& data, const int64_t timestamp)
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet");
|
||||
}
|
||||
|
||||
if (timestamp < pwalletMain->nTimeFirstKey) {
|
||||
pwalletMain->nTimeFirstKey = timestamp;
|
||||
}
|
||||
pwalletMain->UpdateTimeFirstKey(timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -912,9 +909,7 @@ UniValue ProcessImport(const UniValue& data, const int64_t timestamp)
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet");
|
||||
}
|
||||
|
||||
if (timestamp < pwalletMain->nTimeFirstKey) {
|
||||
pwalletMain->nTimeFirstKey = timestamp;
|
||||
}
|
||||
pwalletMain->UpdateTimeFirstKey(timestamp);
|
||||
|
||||
success = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user