Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Remove hash records after 2 rounds instead of 100 steps.
Browse files Browse the repository at this point in the history
  • Loading branch information
afck committed Oct 11, 2019
1 parent fd1b547 commit 8581b8c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ethcore/engines/authority-round/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1401,9 +1401,10 @@ impl Engine for AuthorityRound {
self.received_step_hashes.write().insert(received_step_key, new_hash);
}

// Remove hash records older than 100 steps (picked as a reasonable trade-off between memory consumption and fault-tolerance).
const SIBLING_MALICE_DETECTION_PERIOD: u64 = 100;
let oldest_step = parent_step.saturating_sub(SIBLING_MALICE_DETECTION_PERIOD);
// Remove hash records older than two full rounds of steps (picked as a reasonable trade-off between
// memory consumption and fault-tolerance).
let sibling_malice_detection_period = 2 * validators.count(&parent.hash()) as u64;
let oldest_step = parent_step.saturating_sub(sibling_malice_detection_period);
if oldest_step > 0 {
let mut rsh = self.received_step_hashes.write();
let new_rsh = rsh.split_off(&(oldest_step, Address::zero()));
Expand Down

0 comments on commit 8581b8c

Please sign in to comment.