Dandelion relay update (#825)

* Change error logger to debug logger
* Dandelion relay update after monitor peers
* Typo + kick off Travis build
This commit is contained in:
Quentin Le Sceller 2018-03-22 18:51:09 -04:00 committed by Ignotus Peverell
parent 155bab93a4
commit 836391cc53
3 changed files with 23 additions and 33 deletions

View file

@ -65,6 +65,8 @@ pub fn connect_and_monitor(
// monitor additional peers if we need to add more
monitor_peers(peers.clone(), capabilities, tx.clone());
update_dandelion_relay(peers.clone());
prev = current_time;
}
@ -93,21 +95,6 @@ fn monitor_peers(
total_count,
);
// Dandelion Relay Updater
let dandelion_relay = peers.get_dandelion_relay();
if dandelion_relay.is_empty() {
debug!(LOGGER, "monitor_peers: no dandelion relay updating");
peers.update_dandelion_relay();
} else {
for last_added in dandelion_relay.keys() {
let dandelion_interval = now_utc().to_timespec().sec - last_added;
if dandelion_interval >= DANDELION_RELAY_TIME {
debug!(LOGGER, "monitor_peers: updating expired dandelion relay");
peers.update_dandelion_relay();
}
}
}
let mut healthy_count = 0;
let mut banned_count = 0;
let mut defunct_count = 0;
@ -168,6 +155,23 @@ fn monitor_peers(
}
}
fn update_dandelion_relay(peers: Arc<p2p::Peers>) {
// Dandelion Relay Updater
let dandelion_relay = peers.get_dandelion_relay();
if dandelion_relay.is_empty() {
debug!(LOGGER, "monitor_peers: no dandelion relay updating");
peers.update_dandelion_relay();
} else {
for last_added in dandelion_relay.keys() {
let dandelion_interval = now_utc().to_timespec().sec - last_added;
if dandelion_interval >= DANDELION_RELAY_TIME {
debug!(LOGGER, "monitor_peers: updating expired dandelion relay");
peers.update_dandelion_relay();
}
}
}
}
// Check if we have any pre-existing peer in db. If so, start with those,
// otherwise use the seeds provided.
fn connect_to_seeds(

View file

@ -92,7 +92,7 @@ impl Peers {
peer.try_read().unwrap().info.addr
);
}
None => error!(LOGGER, "Could not update dandelion relay"),
None => debug!(LOGGER, "Could not update dandelion relay"),
};
}
// Get the dandelion relay

View file

@ -271,7 +271,7 @@ where
Parent::StemPoolTransaction { tx_ref: x } => {
if will_stem {
// Going to stem this transaction if parent is in stempool it's ok.
debug!(LOGGER, "Going is in stempool");
debug!(LOGGER, "Going in stempool");
pool_refs.push(base.with_source(Some(x)));
} else {
will_stem = true;
@ -1711,14 +1711,7 @@ mod tests {
let keychain = keychain_for_tests();
let key_id = keychain.derive_key_id(value as u32).unwrap();
let commit = keychain.commit(value, &key_id).unwrap();
let proof = keychain
.range_proof(
value,
&key_id,
commit,
None,
)
.unwrap();
let proof = keychain.range_proof(value, &key_id, commit, None).unwrap();
transaction::Output {
features: transaction::OutputFeatures::DEFAULT_OUTPUT,
@ -1732,14 +1725,7 @@ mod tests {
let keychain = keychain_for_tests();
let key_id = keychain.derive_key_id(value as u32).unwrap();
let commit = keychain.commit(value, &key_id).unwrap();
let proof = keychain
.range_proof(
value,
&key_id,
commit,
None,
)
.unwrap();
let proof = keychain.range_proof(value, &key_id, commit, None).unwrap();
transaction::Output {
features: transaction::OutputFeatures::COINBASE_OUTPUT,