Flexible peer filtering (#3458)

* first pass at peers iter cleanup

* more flexible peer with diff lookups

* PeersIter with impl Iterator

* sync against outbound peers
reorder peers filters so expensive filters come later

* filter peers by capabilities during sync

* prefer outbound peers with high total difficulty

* with_difficulty now takes a fn to allow more flexible comparisons based on difficulty

* rename peers_iter() -> iter()
This commit is contained in:
Antioch Peverell
2020-10-27 12:36:00 +00:00
committed by GitHub
parent cea546ceb8
commit 25fcefada2
13 changed files with 235 additions and 183 deletions
+7 -1
View File
@@ -21,6 +21,7 @@ use crate::types::*;
use crate::web::*;
use hyper::{Body, Request};
use serde_json::json;
use std::convert::TryInto;
use std::sync::Weak;
// RESTful index of available api endpoints
@@ -54,7 +55,12 @@ impl StatusHandler {
let (api_sync_status, api_sync_info) = sync_status_to_api(sync_status);
Ok(Status::from_tip_and_peers(
head,
w(&self.peers)?.peer_count(),
w(&self.peers)?
.iter()
.connected()
.count()
.try_into()
.unwrap(),
api_sync_status,
api_sync_info,
))