mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 02:05:30 +00:00
WIP: work on http load test (now partly working) and http protocol
This commit is contained in:
parent
5b0d364ccf
commit
d1e9d24773
10 changed files with 326 additions and 226 deletions
|
|
@ -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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue