Browse Source

Merge #9827: Improve ScanForWalletTransactions return value

30abce7 Improve ScanForWalletTransactions return value (Russell Yanofsky)

Tree-SHA512: 195028553b103052a842b6a37e67410118a20c32475b80f7fd22d6d8622f92eca1c2d84f291d1092bef2161d3187d91052799b533e1e265b7613d51955490b8d
0.15
Wladimir J. van der Laan 8 years ago
parent
commit
c91ca0ace9
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 11
      src/wallet/test/wallet_tests.cpp
  2. 7
      src/wallet/wallet.cpp

11
src/wallet/test/wallet_tests.cpp

@ -424,6 +424,17 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup) @@ -424,6 +424,17 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup)
BOOST_CHECK_EQUAL(response.write(), strprintf("[{\"success\":false,\"error\":{\"code\":-1,\"message\":\"Failed to rescan before time %d, transactions may be missing.\"}},{\"success\":true}]", newTip->GetBlockTimeMax()));
::pwalletMain = backup;
}
// Verify ScanForWalletTransactions does not return null when the scan is
// elided due to the nTimeFirstKey optimization.
{
CWallet wallet;
{
LOCK(wallet.cs_wallet);
wallet.UpdateTimeFirstKey(newTip->GetBlockTime() + 7200 + 1);
}
BOOST_CHECK_EQUAL(newTip, wallet.ScanForWalletTransactions(newTip));
}
}
// Check that GetImmatureCredit() returns a newly calculated value instead of

7
src/wallet/wallet.cpp

@ -1515,16 +1515,17 @@ void CWalletTx::GetAccountAmounts(const std::string& strAccount, CAmount& nRecei @@ -1515,16 +1515,17 @@ void CWalletTx::GetAccountAmounts(const std::string& strAccount, CAmount& nRecei
* exist in the wallet will be updated.
*
* Returns pointer to the first block in the last contiguous range that was
* successfully scanned.
*
* successfully scanned or elided (elided if pIndexStart points at a block
* before CWallet::nTimeFirstKey). Returns null if there is no such range, or
* the range doesn't include chainActive.Tip().
*/
CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
{
CBlockIndex* ret = nullptr;
int64_t nNow = GetTime();
const CChainParams& chainParams = Params();
CBlockIndex* pindex = pindexStart;
CBlockIndex* ret = pindexStart;
{
LOCK2(cs_main, cs_wallet);
fAbortRescan = false;

Loading…
Cancel
Save