Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Filter-out nodes.json (#7716)
Browse files Browse the repository at this point in the history
* Filter-out nodes.json

* network: sort node table nodes by failure ratio

* network: fix node table tests

* network: fit node failure percentage into buckets of 5%

* network: consider number of attempts in sorting of node table

* network: fix node table grumbles
  • Loading branch information
tomusdrw authored and 5chdn committed Jan 31, 2018
1 parent a412f7c commit f5c68c6
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 98 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions util/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ ethcore-logger = { path ="../../logger" }
ipnetwork = "0.12.6"
keccak-hash = { path = "../hash" }
snappy = { git = "https://github.com/paritytech/rust-snappy" }
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
error-chain = { version = "0.11", default-features = false }

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions util/network/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ impl Host {
let address = {
let mut nodes = self.nodes.write();
if let Some(node) = nodes.get_mut(id) {
node.last_attempted = Some(::time::now());
node.attempts += 1;
node.endpoint.address
}
else {
Expand All @@ -738,6 +738,7 @@ impl Host {
}
}
};

if let Err(e) = self.create_connection(socket, Some(id), io) {
debug!(target: "network", "Can't create connection: {:?}", e);
}
Expand Down Expand Up @@ -1281,4 +1282,3 @@ fn host_client_url() {
let host: Host = Host::new(config, Arc::new(NetworkStats::new()), None).unwrap();
assert!(host.local_url().starts_with("enode://101b3ef5a4ea7a1c7928e24c4c75fd053c235d7b80c22ae5c03d145d0ac7396e2a4ffff9adee3133a7b05044a5cee08115fd65145e5165d646bde371010d803c@"));
}

5 changes: 3 additions & 2 deletions util/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,16 @@ extern crate path;
extern crate ethcore_logger;
extern crate ipnetwork;
extern crate keccak_hash as hash;
extern crate serde;
extern crate serde_json;
extern crate snappy;

#[macro_use]
extern crate error_chain;

#[macro_use]
extern crate log;
#[macro_use]
extern crate serde_derive;

#[cfg(test)]
extern crate tempdir;
Expand Down Expand Up @@ -207,4 +209,3 @@ pub enum AllowIP {
/// Block all addresses
None,
}

Loading

0 comments on commit f5c68c6

Please sign in to comment.