core, ethdb, trie: mode dirty data to clean cache on flush (#19307)

This PR is a more advanced form of the dirty-to-clean cacher (#18995),
where we reuse previous database write batches as datasets to uncache,
saving a dirty-trie-iteration and a dirty-trie-rlp-reencoding per block.
This commit is contained in:
Martin Holst Swende
2019-03-26 15:48:31 +01:00
committed by Felix Lange
parent df717abc99
commit 59e1953246
12 changed files with 156 additions and 67 deletions

View File

@ -240,6 +240,22 @@ func (b *batch) Reset() {
b.size = 0
}
// Replay replays the batch contents.
func (b *batch) Replay(w ethdb.Writer) error {
for _, keyvalue := range b.writes {
if keyvalue.delete {
if err := w.Delete(keyvalue.key); err != nil {
return err
}
continue
}
if err := w.Put(keyvalue.key, keyvalue.value); err != nil {
return err
}
}
return nil
}
// iterator can walk over the (potentially partial) keyspace of a memory key
// value store. Internally it is a deep copy of the entire iterated state,
// sorted by keys.