fn apply_byzantine_faults(counters: Vec<RewardCounter>) -> Vec<RewardCounter> {
        let mut rng = rand::thread_rng();
        let mut byzantine_elders = HashSet::new();
        let quorum = (counters.len() / 3) * 2;
        let max_byzantine = quorum - 1;
        while max_byzantine > byzantine_elders.len() {
            let _ = byzantine_elders.insert(rng.gen_range(0, counters.len()));
        }
        let mut faulty_counters = counters;
        for i in byzantine_elders {
            faulty_counters[i] = RewardCounter {
                reward: Money::from_nano(rng.next_u64()), // wildly wrong/dishonest
                work: rng.next_u64(),                     // wildly wrong/dishonest
            };
        }
        faulty_counters
    }
// Four out of seven Elders will be correct/honest.
// Three out of seven Elders will be wildly wrong/dishonest.
Four out of seven Elders will be correct/honest.
Three out of seven Elders will be wildly wrong/dishonest.
Four out of seven Elders will be correct / honest . Three out of seven Elders will be wildly wrong / dishonest .
fn apply_byzantine_faults(counters: Vec<RewardCounter>) -> Vec<RewardCounter> {
        let mut rng = rand::thread_rng();
        let mut byzantine_elders = HashSet::new();
        let quorum = (counters.len() / 3) * 2;
        let max_byzantine = quorum - 1;
        while max_byzantine > byzantine_elders.len() {
            let _ = byzantine_elders.insert(rng.gen_range(0, counters.len()));
        }
        let mut faulty_counters = counters;
        for i in byzantine_elders {
            faulty_counters[i] = RewardCounter {
                reward: Money::from_nano(rng.next_u64()), // wildly wrong/dishonest
                work: rng.next_u64(),                     // wildly wrong/dishonest
            };
        }
        faulty_counters
    }
fn apply_byzantine_faults ( counters : Vec < RewardCounter > ) -> Vec < RewardCounter > { let mut rng = rand :: thread_rng ( ) ; let mut byzantine_elders = HashSet :: new ( ) ; let quorum = ( counters . len ( ) / 3 ) * 2 ; let max_byzantine = quorum - 1 ; while max_byzantine > byzantine_elders . len ( ) { let _ = byzantine_elders . insert ( rng . gen_range ( 0 , counters . len ( ) ) ) ; } let mut faulty_counters = counters ; for i in byzantine_elders { faulty_counters [ i ] = RewardCounter { reward : Money :: from_nano ( rng . next_u64 ( ) ) , // wildly wrong/dishonest work : rng . next_u64 ( ) , // wildly wrong/dishonest } ; } faulty_counters }
Four out of seven Elders will be correct/honest.
Four out of seven Elders will be correct / honest .
counters
Vec<RewardCounter>
counters
Vec<RewardCounter>