-
Notifications
You must be signed in to change notification settings - Fork 1.7k
UDP Discovery #440
Changes from all commits
09b6503
48924f4
2af379d
62b9f4b
76ea030
9768fdd
2d89708
718646f
7503d66
dee375b
fc7483a
61c52f1
38f4a06
986448c
186c758
ba95260
cf45d59
4d40991
3096892
0e1e804
4b9c7f7
01a83e6
a2c0508
0bef355
64913d5
fb0b5b2
dbf3691
681350b
2039473
f771306
58fdfe7
c5ca293
fa316c2
33e8d74
d95e971
a4ea073
f4fa747
217cbec
4f73d63
fbe06d3
7e0dfb4
b6ccbdb
0b916e0
39a98cd
a179722
e4baf37
eef193e
c9f3f5e
0cfc4cb
e0623f5
d9fec87
1d60d82
85c842b
beab90c
ab233a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ extern crate ethcore_rpc as rpc; | |
|
||
use std::net::{SocketAddr}; | ||
use std::env; | ||
use std::path::PathBuf; | ||
use rlog::{LogLevelFilter}; | ||
use env_logger::LogBuilder; | ||
use ctrlc::CtrlC; | ||
|
@@ -69,8 +70,10 @@ Options: | |
|
||
--no-bootstrap Don't bother trying to connect to any nodes initially. | ||
--listen-address URL Specify the IP/port on which to listen for peers [default: 0.0.0.0:30304]. | ||
--public-address URL Specify the IP/port on which peers may connect [default: 0.0.0.0:30304]. | ||
--public-address URL Specify the IP/port on which peers may connect. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Defaults are now determined by the networking layer and not by docopts. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how does the user know which the default listen port is? |
||
--address URL Equivalent to --listen-address URL --public-address URL. | ||
--peers NUM Try to manintain that many peers [default: 25]. | ||
--no-discovery Disable new peer discovery. | ||
--upnp Use UPnP to try to figure out the correct network settings. | ||
--node-key KEY Specify node secret key as hex string. | ||
|
||
|
@@ -95,8 +98,10 @@ struct Args { | |
flag_keys_path: String, | ||
flag_no_bootstrap: bool, | ||
flag_listen_address: String, | ||
flag_public_address: String, | ||
flag_public_address: Option<String>, | ||
flag_address: Option<String>, | ||
flag_peers: u32, | ||
flag_no_discovery: bool, | ||
flag_upnp: bool, | ||
flag_node_key: Option<String>, | ||
flag_cache_pref_size: usize, | ||
|
@@ -165,7 +170,7 @@ impl Configuration { | |
self.args.flag_db_path.replace("$HOME", env::home_dir().unwrap().to_str().unwrap()) | ||
} | ||
|
||
fn keys_path(&self) -> String { | ||
fn _keys_path(&self) -> String { | ||
self.args.flag_keys_path.replace("$HOME", env::home_dir().unwrap().to_str().unwrap()) | ||
} | ||
|
||
|
@@ -187,21 +192,23 @@ impl Configuration { | |
} | ||
} | ||
|
||
fn net_addresses(&self) -> (SocketAddr, SocketAddr) { | ||
let listen_address; | ||
let public_address; | ||
fn net_addresses(&self) -> (Option<SocketAddr>, Option<SocketAddr>) { | ||
let mut listen_address = None; | ||
let mut public_address = None; | ||
|
||
match self.args.flag_address { | ||
None => { | ||
listen_address = SocketAddr::from_str(self.args.flag_listen_address.as_ref()).expect("Invalid listen address given with --listen-address"); | ||
public_address = SocketAddr::from_str(self.args.flag_public_address.as_ref()).expect("Invalid public address given with --public-address"); | ||
} | ||
Some(ref a) => { | ||
public_address = SocketAddr::from_str(a.as_ref()).expect("Invalid listen/public address given with --address"); | ||
listen_address = public_address; | ||
if let Some(ref a) = self.args.flag_address { | ||
public_address = Some(SocketAddr::from_str(a.as_ref()).expect("Invalid listen/public address given with --address")); | ||
listen_address = public_address; | ||
} | ||
if listen_address.is_none() { | ||
listen_address = Some(SocketAddr::from_str(self.args.flag_listen_address.as_ref()).expect("Invalid listen address given with --listen-address")); | ||
} | ||
if let Some(ref a) = self.args.flag_public_address { | ||
if public_address.is_some() { | ||
panic!("Conflicting flags: --address and --public-address"); | ||
} | ||
}; | ||
|
||
public_address = Some(SocketAddr::from_str(a.as_ref()).expect("Invalid listen address given with --public-address")); | ||
} | ||
(listen_address, public_address) | ||
} | ||
|
||
|
@@ -236,6 +243,11 @@ impl Configuration { | |
net_settings.listen_address = listen; | ||
net_settings.public_address = public; | ||
net_settings.use_secret = self.args.flag_node_key.as_ref().map(|s| Secret::from_str(&s).expect("Invalid key string")); | ||
net_settings.discovery_enabled = !self.args.flag_no_discovery; | ||
net_settings.ideal_peers = self.args.flag_peers; | ||
let mut net_path = PathBuf::from(&self.path()); | ||
net_path.push("network"); | ||
net_settings.config_path = Some(net_path.to_str().unwrap().to_owned()); | ||
|
||
// Build client | ||
let mut service = ClientService::start(spec, net_settings, &Path::new(&self.path())).unwrap(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,7 @@ const RECEIPTS_PACKET: u8 = 0x10; | |
|
||
const NETWORK_ID: U256 = ONE_U256; //TODO: get this from parent | ||
|
||
const CONNECTION_TIMEOUT_SEC: f64 = 30f64; | ||
const CONNECTION_TIMEOUT_SEC: f64 = 10f64; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Large timeout and high import speed leads to block queue underrun and sync stalling when waiting for a unresponsive peer for too long. |
||
|
||
struct Header { | ||
/// Header data | ||
|
@@ -314,7 +314,7 @@ impl ChainSync { | |
} | ||
|
||
self.peers.insert(peer_id.clone(), peer); | ||
info!(target: "sync", "Connected {}:{}", peer_id, io.peer_info(peer_id)); | ||
debug!(target: "sync", "Connected {}:{}", peer_id, io.peer_info(peer_id)); | ||
self.sync_peer(io, peer_id, false); | ||
Ok(()) | ||
} | ||
|
@@ -545,7 +545,7 @@ impl ChainSync { | |
pub fn on_peer_aborting(&mut self, io: &mut SyncIo, peer: PeerId) { | ||
trace!(target: "sync", "== Disconnecting {}", peer); | ||
if self.peers.contains_key(&peer) { | ||
info!(target: "sync", "Disconnected {}", peer); | ||
debug!(target: "sync", "Disconnected {}", peer); | ||
self.clear_peer_download(peer); | ||
self.peers.remove(&peer); | ||
self.continue_sync(io); | ||
|
@@ -1179,7 +1179,7 @@ impl ChainSync { | |
for (peer_id, peer_number) in updated_peers { | ||
let mut peer_best = self.peers.get(&peer_id).unwrap().latest_hash.clone(); | ||
if best_number - peer_number > MAX_PEERS_PROPAGATION as BlockNumber { | ||
// If we think peer is too far behind just end one latest hash | ||
// If we think peer is too far behind just send one latest hash | ||
peer_best = last_parent.clone(); | ||
} | ||
sent = sent + match ChainSync::create_new_hashes_rlp(io.chain(), &peer_best, &local_best) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevents panic when someone requests NodeData from us