Skip to content

Commit

Permalink
Merge pull request #260 from Rqnsom/update_collector
Browse files Browse the repository at this point in the history
chore(synth_node_bin): rt_collector improvements
  • Loading branch information
Rqnsom authored Jul 10, 2023
2 parents 5c6f7d0 + 932d6be commit 5e8761a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use rand::{
rngs::StdRng,
SeedableRng,
};
use tokio::time::{sleep, Duration};
use ziggurat_zcash::{
protocol::{
message::Message,
Expand Down Expand Up @@ -82,7 +81,7 @@ impl SynthNodeAction for Action {
min = elapsed;
}

avg = avg + elapsed;
avg += elapsed;

count += 1;

Expand Down
11 changes: 10 additions & 1 deletion synth_node_bin/src/action/rt_s1_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use ziggurat_zcash::{
use super::{ActionCfg, SynthNodeAction};

// Configurable status printout interval.
const BROADCAST_INTERVAL_SEC: Duration = Duration::from_secs(3);
const BROADCAST_INTERVAL_SEC: Duration = Duration::from_secs(60);
const DBG_INFO_LOG_INTERVAL_SEC: Duration = Duration::from_secs(10);

const MAX_PEER_LIST_LEN: usize = 1000;
Expand All @@ -38,6 +38,7 @@ impl SynthNodeAction for Action {
network_cfg: NodeConfig {
listener_ip: Some(IpAddr::V4(Ipv4Addr::UNSPECIFIED)),
desired_listening_port: Some(18233),
max_connections: 3000,
..Default::default()
},
allow_proper_shutdown: true,
Expand All @@ -48,6 +49,7 @@ impl SynthNodeAction for Action {
async fn run(&self, synth_node: &mut SyntheticNode, addr: Option<SocketAddr>) -> Result<()> {
let mut broadcast_msgs_interval = interval(BROADCAST_INTERVAL_SEC);
let mut dbg_info_interval = interval(DBG_INFO_LOG_INTERVAL_SEC);
let mut num_connected = synth_node.num_connected();

loop {
tokio::select! {
Expand All @@ -57,6 +59,13 @@ impl SynthNodeAction for Action {
},
// Broadcast an Addr message to all peers.
_ = broadcast_msgs_interval.tick() => {
let num_connected_new = synth_node.num_connected();

if num_connected == num_connected_new {
continue;
}

num_connected = num_connected_new;
let _ = broadcast_addr_msg(synth_node);
},
// Clear inbound queue.
Expand Down
1 change: 1 addition & 0 deletions synth_node_bin/src/action/rt_s1_tainter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ impl SynthNodeAction for Action {
network_cfg: NodeConfig {
listener_ip: Some(IpAddr::V4(Ipv4Addr::UNSPECIFIED)),
desired_listening_port: Some(8233),
max_connections: 1000,
..Default::default()
},
allow_proper_shutdown: true,
Expand Down

0 comments on commit 5e8761a

Please sign in to comment.