Skip to content

Commit 502522a

Browse files
apollo_network_benchmark: added broadcasting mode selection
1 parent a00a4b2 commit 502522a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

crates/apollo_network_benchmark/src/node_args.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,29 @@ use std::fmt::Display;
33
use clap::{Parser, ValueEnum};
44
use serde::{Deserialize, Serialize};
55

6+
#[derive(Debug, Clone, ValueEnum, PartialEq, Eq, Serialize, Deserialize)]
7+
pub enum Mode {
8+
/// All nodes broadcast messages
9+
#[value(name = "all")]
10+
AllBroadcast,
11+
/// Only the node specified by --broadcaster broadcasts messages
12+
#[value(name = "one")]
13+
OneBroadcast,
14+
}
15+
616
#[derive(Debug, Clone, ValueEnum, PartialEq, Eq, Serialize, Deserialize)]
717
pub enum NetworkProtocol {
818
/// Use gossipsub for broadcasting (default)
919
#[value(name = "gossipsub")]
1020
Gossipsub,
1121
}
1222

23+
impl Display for Mode {
24+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25+
write!(f, "{}", self.to_possible_value().unwrap().get_name())
26+
}
27+
}
28+
1329
impl Display for NetworkProtocol {
1430
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1531
write!(f, "{}", self.to_possible_value().unwrap().get_name())
@@ -49,10 +65,18 @@ pub struct UserArgs {
4965
#[arg(long, env, default_value = "100000")]
5066
pub buffer_size: usize,
5167

68+
/// The mode to use for the stress test.
69+
#[arg(long, env, default_value = "all")]
70+
pub mode: Mode,
71+
5272
/// The network protocol to use for communication (default: gossipsub)
5373
#[arg(long, env, default_value = "gossipsub")]
5474
pub network_protocol: NetworkProtocol,
5575

76+
/// Which node ID should do the broadcasting - for OneBroadcast mode
77+
#[arg(long, env, required_if_eq("mode", "one"))]
78+
pub broadcaster: Option<u64>,
79+
5680
/// Size of StressTestMessage
5781
#[arg(long, env, default_value = "1024")]
5882
pub message_size_bytes: usize,

0 commit comments

Comments
 (0)