mirror of
https://github.com/logos-blockchain/logos-blockchain-simulations.git
synced 2026-05-01 23:43:11 +00:00
* Rename to netrunner * Refactor sims structure * Add missing workspace cargo * Rebase changes * Rebase changes * Rebase changes * Fix tests
23 lines
371 B
Rust
23 lines
371 B
Rust
use rand::Rng;
|
|
|
|
pub struct StakeLottery<R> {
|
|
rng: R,
|
|
stake_proportion: f64,
|
|
}
|
|
|
|
impl<R> StakeLottery<R>
|
|
where
|
|
R: Rng,
|
|
{
|
|
pub fn new(rng: R, stake_proportion: f64) -> Self {
|
|
Self {
|
|
rng,
|
|
stake_proportion,
|
|
}
|
|
}
|
|
|
|
pub fn run(&mut self) -> bool {
|
|
self.rng.gen_range(0.0..1.0) < self.stake_proportion
|
|
}
|
|
}
|