WIP: aquatic_ws: add half-crappy load test, fix infinite loop bug

This commit is contained in:
Joakim Frostegård 2020-08-01 03:35:00 +02:00
parent c7be84a61e
commit a5108f813d
17 changed files with 821 additions and 10 deletions

View file

@ -0,0 +1,41 @@
use std::sync::{Arc, atomic::AtomicUsize};
use rand_distr::Pareto;
pub use aquatic_ws_protocol::*;
#[derive(PartialEq, Eq, Clone)]
pub struct TorrentPeer {
pub info_hash: InfoHash,
pub scrape_hash_indeces: Vec<usize>,
pub peer_id: PeerId,
pub port: u16,
}
#[derive(Default)]
pub struct Statistics {
pub requests: AtomicUsize,
pub response_peers: AtomicUsize,
pub responses_announce: AtomicUsize,
pub responses_scrape: AtomicUsize,
pub responses_failure: AtomicUsize,
pub bytes_sent: AtomicUsize,
pub bytes_received: AtomicUsize,
}
#[derive(Clone)]
pub struct LoadTestState {
pub info_hashes: Arc<Vec<InfoHash>>,
pub statistics: Arc<Statistics>,
pub pareto: Arc<Pareto<f64>>,
}
#[derive(PartialEq, Eq, Clone, Copy)]
pub enum RequestType {
Announce,
Scrape
}