Simulation prune tally (#299)
* Add pruning methods * Call pruning on node step method * Fix tally retain closure
This commit is contained in:
parent
da60d8fc95
commit
ef5935d572
|
@ -36,6 +36,15 @@ impl EventBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
/// At some point we need to clear old votes or RAM just goes brrrrrr
|
||||
pub fn prune_by_view(&mut self, view: View) {
|
||||
self.vote_message.prune(view);
|
||||
self.leader_vote_message.prune(view);
|
||||
self.timeout_message.prune(view);
|
||||
self.leader_new_view_message.prune(view);
|
||||
self.new_view_message.prune(view);
|
||||
}
|
||||
|
||||
fn local_timeout(&mut self, view: View, elapsed: Duration) -> bool {
|
||||
if self.timeout_handler.step(view, elapsed) {
|
||||
self.timeout_handler.prune_by_view(view);
|
||||
|
|
|
@ -533,6 +533,8 @@ impl<
|
|||
|| matches!(m, CarnotMessage::Proposal(_) | CarnotMessage::TimeoutQc(_))
|
||||
});
|
||||
self.message_cache.prune(self.engine.current_view().prev());
|
||||
self.event_builder
|
||||
.prune_by_view(self.engine.current_view().prev());
|
||||
self.message_cache.update(other_view_messages);
|
||||
current_view_messages.append(&mut self.message_cache.retrieve(self.engine.current_view()));
|
||||
|
||||
|
|
|
@ -22,4 +22,8 @@ impl<T: core::hash::Hash + Eq + Clone> Tally<T> {
|
|||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn prune(&mut self, view: View) {
|
||||
self.cache.retain(|v, _| v > &view);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue