In commit “refactor: Remove redundant reindex check” (fd590d5ca1cfb6c2525b7755edb6a3a2cf16c856)
Curious about something: In #30965 (comment) you wrote,
Yes, my eventual goal was to move calling InitializeChainstate
for the fully validated chainstate into the ChainstateManager
constructor as well as calling InitCoinsDB
for it. I wanted to do this in a future pull request if this change is accepted.
So if coins db were intialized in the chainstate constructor, then this dbwrapper_error exception could mean there is an error either from the coins db or the blocks db, not just the blocks db as stated in the current error message.
For this reason, and in any case, it seems fragile for this code to have to know what ChainstateManager constructor is doing internally and what exceptions that code might throw. I think it might be better if instead of letting dbwrapper_error be thrown from the ChainstateManager constructor, code in that constructor or code in the BlockStorage constructor would catch that exception and throw a more generic exception that this code could handle without needing to know about ChainstateManager internals.
Maybe a good candidate for a generic exception type could be the existing ChainstateLoadResult
type since it can hold an error message and also indicate whether the error is fatal or not (i.e. whether a reindex should be attempted or not).