Maintain min outbound peers (min_preferred_peers / 2) (#2417)

* outbound connection count

* rustfmt

* display outbound peer count

* rustfmt

* wip - allow connections to exceed max when trying to create new outcound connections
any in excess of total max will be cleaned up subsequently

* fix

* we care about connected outbound peer count when deciding to connect to new peers
This commit is contained in:
Antioch Peverell
2019-01-19 16:13:09 +00:00
committed by GitHub
parent 74422efa5b
commit ef5d83817e
4 changed files with 39 additions and 9 deletions
+9 -2
View File
@@ -135,7 +135,6 @@ impl TUIStatusListener for TUIPeerView {
LinearLayout::new(Orientation::Vertical)
.child(
LinearLayout::new(Orientation::Horizontal)
.child(TextView::new("Total Peers: "))
.child(TextView::new(" ").with_id("peers_total")),
)
.child(
@@ -179,7 +178,15 @@ impl TUIStatusListener for TUIPeerView {
},
);
let _ = c.call_on_id("peers_total", |t: &mut TextView| {
t.set_content(stats.peer_stats.len().to_string());
t.set_content(format!(
"Total Peers: {} (Outbound: {})",
stats.peer_stats.len(),
stats
.peer_stats
.iter()
.filter(|x| x.direction == "Outbound")
.count(),
));
});
let _ = c.call_on_id("longest_work_peer", |t: &mut TextView| {
t.set_content(lp_str);