This PR adds a way to persist the coins cache on shutdown to a file named coinscache.dat
, similar to what is done for the mempool. On startup this file is used to warm the cache so it doesn’t get cold between restarts.
This introduces a new config arg, -persistcoinscache
, that is defaulted to true unless -dbcache
is set to a higher value than default.
With a higher cache value the amount of disk space used for the file could be very large and the warm up could take an excessively long time, so it defaults to off to prevent any footguns. With a max dbcache after a reindex or IBD it will dump the entire utxo set and load it into memory on startup. Testing this today I had a file size of 2.4GB and it took ~22 minutes to warm the cache with an SSD.
After #17487 we can add a change to not wipe the cache on periodic flushes. We could then run the node continuously with the entire utxo set in memory. This could be useful for users who want to connect blocks quickly.
I’m not sure how I should write tests for this.