Merge #13428: validation: check the specified number of blocks (off-by-one)

f6f8026e40326e74293dc8ecc270a7e3b4850727 validation: check the specified number of blocks (off-by-one) (Karl-Johan Alm)

Pull request description:

  ```
  echeveria | 2018-06-11 02:03:03.384975 Verifying last 3 blocks at level 3
  echeveria | 2018-06-11 02:03:23.676793 No coin database inconsistencies in last 4 blocks (6564 transactions)
  echeveria | off by one?
  sipa      | echeveria: possibly!
  kallewoof | Looks like it checks one more block than suggested. `if (pindex->nHeight < chainActive.Height()-nCheckDepth) break;` should probably be `<=`.
  sipa      | kallewoof: agree
  ```

  Post-commit:
  ```
  2018-06-11T05:24:02Z Verifying last 6 blocks at level 3
  2018-06-11T05:24:02Z [0%]...[16%]...[33%]...[50%]...[66%]...[83%]...[99%]...[DONE].
  2018-06-11T05:25:07Z No coin database inconsistencies in last 6 blocks (7258 transactions)
  ```

  Pre-commit:
  ```
  2018-06-11T05:27:11Z Verifying last 6 blocks at level 3
  2018-06-11T05:27:11Z [0%]...[16%]...[33%]...[50%]...[66%]...[83%]...[99%]...[DONE].
  2018-06-11T05:27:12Z No coin database inconsistencies in last 7 blocks (9832 transactions)
  ```

Tree-SHA512: 6e68dc4ba74232518c2ba8ea624d65893534f3619d43ccdf0b9c65992f25b68cb52cf54fa35e6e3d092d1eee5c9a8887057828895f1acdafc0ebb48f683fffdc
This commit is contained in:
Wladimir J. van der Laan 2018-06-13 15:42:07 +02:00 committed by pasta
parent 442e54e851
commit eea8da81c5

View File

@ -4243,7 +4243,7 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview,
reportDone = percentageDone/10; reportDone = percentageDone/10;
} }
uiInterface.ShowProgress(_("Verifying blocks..."), percentageDone, false); uiInterface.ShowProgress(_("Verifying blocks..."), percentageDone, false);
if (pindex->nHeight < chainActive.Height()-nCheckDepth) if (pindex->nHeight <= chainActive.Height()-nCheckDepth)
break; break;
if (fPruneMode && !(pindex->nStatus & BLOCK_HAVE_DATA)) { if (fPruneMode && !(pindex->nStatus & BLOCK_HAVE_DATA)) {
// If pruning, only go back as far as we have data. // If pruning, only go back as far as we have data.