This resets the index dbs when running -reindex-chainstate as was previously done only for -reindex.
It fixes two bugs with -reindex-chainstate in conjunction with the indices:
-
coinstatsindexgets corrupted:reindex-chainstateleads toBlockConnected()signals to the index for each block that is reprocessed: If the index db is not reset, the running hashDB_MUHASHis not reset either and it will include data from each block twice after the reindexing, so the MuHash will be incorrect. I added a test for this that fails on master. -
blockfilterindexduplicates the flatfile data: It has a variableDB_FILTER_POSfor the current position which would not get reset. As a result, the filterdata would be written twice to disk in succession.
txindex has no running variable like the other two indexes, but I think that conceptually it makes sense to reset the index db here as well.