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:
-
coinstatsindex
gets corrupted:reindex-chainstate
leads toBlockConnected()
signals to the index for each block that is reprocessed: If the index db is not reset, the running hashDB_MUHASH
is 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. -
blockfilterindex
duplicates the flatfile data: It has a variableDB_FILTER_POS
for 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.