bitcoin/bitcoin — pull request #4834 by sipa (2014-09-03 12:44:40+00:00)
Title: Simplify coins cache and drop fully spent unwritten entries

Replace the CCoinsViewCache interface with mostly just AccessCoins and ModifyCoins methods (see individual commits), and maintain metadata about cached entries.

This allows us to know when a transaction is fully spent before it is flushed, allowing us to forget about it entirely and never have it touch disk at all.

With this, I can -reindex the main chain until the last checkpoint with around 2GB (without any chainstate write to disk) of RSS. The final dump of the result to LevelDB takes 700MB extra.

Note that this is just a memory usage improvement, and not a performance optimization as such: it doesn't attempt to keep modified non-dirty entries in memory, or do negative caching.