Flushing the dbcache is the mechanism by which the database on disk is introduced in sync with the database in reminiscence. For the reason that UTXO set continually adjustments, it is extra performant to cache the newest adjustments in reminiscence slightly than writing every thing out to disk instantly as disk I/O might be fairly sluggish.
As a result of entries contained within the dbcache are usually not at all times on disk, an occasion that kills bitcoind earlier than the flush can happen (resembling sudden energy loss) leads to these UTXO set adjustments being misplaced. However this isn’t catastrophic so long as we nonetheless have the blocks. We are able to simply load up the chainstate with the newest information, and undergo these blocks once more to replace the chainstate.
With pruning, we’re going to be deleting blocks. This introduces a state of affairs the place we have now UTXO set adjustments within the dbcache however not on disk and the blocks originating these adjustments have been eliminated. If bitcoind have been to be killed presently, we might don’t have any manner of recovering the adjustments with out re-downloading the blocks. By flushing the dbcache earlier than eradicating the blk*.dat and undo*.dat information, we will be certain that the UTXO set on disk is updated earlier than the information are pruned.
