+impl ConnectStyle {
+ fn random_style() -> ConnectStyle {
+ #[cfg(feature = "std")] {
+ use core::hash::{BuildHasher, Hasher};
+ // Get a random value using the only std API to do so - the DefaultHasher
+ let rand_val = std::collections::hash_map::RandomState::new().build_hasher().finish();
+ let res = match rand_val % 7 {
+ 0 => ConnectStyle::BestBlockFirst,
+ 1 => ConnectStyle::BestBlockFirstSkippingBlocks,
+ 2 => ConnectStyle::BestBlockFirstReorgsOnlyTip,
+ 3 => ConnectStyle::TransactionsFirst,
+ 4 => ConnectStyle::TransactionsFirstSkippingBlocks,
+ 5 => ConnectStyle::TransactionsFirstReorgsOnlyTip,
+ 6 => ConnectStyle::FullBlockViaListen,
+ _ => unreachable!(),
+ };
+ eprintln!("Using Block Connection Style: {:?}", res);
+ res
+ }
+ #[cfg(not(feature = "std"))] {
+ ConnectStyle::FullBlockViaListen
+ }
+ }
+}
+