Trait hotshot_types::traits::network::NetworkReliability
source · pub trait NetworkReliability:
Debug
+ Sync
+ Send
+ DynClone
+ 'static {
// Provided methods
fn sample_keep(&self) -> bool { ... }
fn sample_delay(&self) -> Duration { ... }
fn scramble(&self, msg: Vec<u8>) -> Vec<u8> ⓘ { ... }
fn sample_repeat(&self) -> usize { ... }
fn chaos_send_msg(
&self,
msg: Vec<u8>,
send_fn: Arc<dyn Send + Sync + Fn(Vec<u8>) -> BoxSyncFuture<'static, ()> + 'static>,
) -> BoxSyncFuture<'static, ()> { ... }
}
Expand description
interface describing how reliable the network is
Provided Methods§
sourcefn sample_keep(&self) -> bool
fn sample_keep(&self) -> bool
Sample from bernoulli distribution to decide whether or not to keep a packet
§Panics
Panics if self.keep_numerator > self.keep_denominator
sourcefn sample_delay(&self) -> Duration
fn sample_delay(&self) -> Duration
sample from uniform distribution to decide whether or not to keep a packet
sourcefn sample_repeat(&self) -> usize
fn sample_repeat(&self) -> usize
number of times to repeat the packet
sourcefn chaos_send_msg(
&self,
msg: Vec<u8>,
send_fn: Arc<dyn Send + Sync + Fn(Vec<u8>) -> BoxSyncFuture<'static, ()> + 'static>,
) -> BoxSyncFuture<'static, ()>
fn chaos_send_msg( &self, msg: Vec<u8>, send_fn: Arc<dyn Send + Sync + Fn(Vec<u8>) -> BoxSyncFuture<'static, ()> + 'static>, ) -> BoxSyncFuture<'static, ()>
given a message and a way to send the message, decide whether or not to send the message how long to delay the message whether or not to send duplicates and whether or not to include noise with the message then send the message note: usually self is stored in a rwlock so instead of doing the sending part, we just fiddle with the message then return a future that does the sending and delaying