WIP: work on http load test (now partly working) and http protocol

This commit is contained in:
Joakim Frostegård 2020-07-20 14:30:36 +02:00
parent 5b0d364ccf
commit d1e9d24773
10 changed files with 326 additions and 226 deletions

View file

@ -11,13 +11,13 @@ pub fn select_info_hash_index(
state: &LoadTestState,
rng: &mut impl Rng,
) -> usize {
pareto_usize(rng, state.pareto, config.handler.number_of_torrents - 1)
pareto_usize(rng, &state.pareto, config.handler.number_of_torrents - 1)
}
pub fn pareto_usize(
rng: &mut impl Rng,
pareto: Arc<Pareto<f64>>,
pareto: &Arc<Pareto<f64>>,
max: usize,
) -> usize {
let p: f64 = pareto.sample(rng);
@ -27,27 +27,6 @@ pub fn pareto_usize(
}
pub fn generate_peer_id() -> PeerId {
PeerId(random_20_bytes())
pub fn generate_info_hash(rng: &mut impl Rng) -> InfoHash {
InfoHash(rng.gen())
}
pub fn generate_info_hash() -> InfoHash {
InfoHash(random_20_bytes())
}
// Don't use SmallRng here for now
fn random_20_bytes() -> [u8; 20] {
let mut bytes = [0; 20];
for (i, b) in rand::thread_rng()
.sample_iter(&Standard)
.enumerate()
.take(20) {
bytes[i] = b
}
bytes
}