mimblewimble / grin

Minimal implementation of the Mimblewimble protocol.
https://grin.mw/
Apache License 2.0
5.04k stars 990 forks source link

rework prune rewrite with iterators #3568

Closed antiochp closed 3 years ago

antiochp commented 3 years ago

This PR refactors the handling of pos_to_rm when pruning during compaction. We used to pass a slice &[u64] around and this has been reworked to accept an IntoIterator<Item = u64>. This allows us to avoid collect() in various places with intermediate memory allocation.

Split save_prune() into two functions for flexibility so we can pass an iterator into the earlier write_tmp_pruned() without needing &mut self (as the iterator passed in has a reference to immutable self).

antiochp commented 3 years ago

This is purely a refactor. We have decent test coverage. Testing locally to ensure we can still prune/compact successfully. Will merge if local testing is good.

antiochp commented 3 years ago
20210219 11:37:56.842 DEBUG grin_chain::txhashset::txhashset - txhashset: starting compaction...
20210219 11:38:23.665 DEBUG grin_chain::txhashset::txhashset - txhashset: check_compact output mmr backend...
20210219 11:38:26.931 DEBUG grin_chain::txhashset::txhashset - txhashset: check_compact rangeproof mmr backend...
20210219 11:38:31.452 DEBUG grin_chain::txhashset::txhashset - txhashset: ... compaction finished