mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
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:
parent
155bab93a4
commit
836391cc53
3 changed files with 23 additions and 33 deletions
|
@ -65,6 +65,8 @@ pub fn connect_and_monitor(
|
||||||
// monitor additional peers if we need to add more
|
// monitor additional peers if we need to add more
|
||||||
monitor_peers(peers.clone(), capabilities, tx.clone());
|
monitor_peers(peers.clone(), capabilities, tx.clone());
|
||||||
|
|
||||||
|
update_dandelion_relay(peers.clone());
|
||||||
|
|
||||||
prev = current_time;
|
prev = current_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,21 +95,6 @@ fn monitor_peers(
|
||||||
total_count,
|
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 healthy_count = 0;
|
||||||
let mut banned_count = 0;
|
let mut banned_count = 0;
|
||||||
let mut defunct_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,
|
// Check if we have any pre-existing peer in db. If so, start with those,
|
||||||
// otherwise use the seeds provided.
|
// otherwise use the seeds provided.
|
||||||
fn connect_to_seeds(
|
fn connect_to_seeds(
|
||||||
|
|
|
@ -92,7 +92,7 @@ impl Peers {
|
||||||
peer.try_read().unwrap().info.addr
|
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
|
// Get the dandelion relay
|
||||||
|
|
|
@ -271,7 +271,7 @@ where
|
||||||
Parent::StemPoolTransaction { tx_ref: x } => {
|
Parent::StemPoolTransaction { tx_ref: x } => {
|
||||||
if will_stem {
|
if will_stem {
|
||||||
// Going to stem this transaction if parent is in stempool it's ok.
|
// 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)));
|
pool_refs.push(base.with_source(Some(x)));
|
||||||
} else {
|
} else {
|
||||||
will_stem = true;
|
will_stem = true;
|
||||||
|
@ -1711,14 +1711,7 @@ mod tests {
|
||||||
let keychain = keychain_for_tests();
|
let keychain = keychain_for_tests();
|
||||||
let key_id = keychain.derive_key_id(value as u32).unwrap();
|
let key_id = keychain.derive_key_id(value as u32).unwrap();
|
||||||
let commit = keychain.commit(value, &key_id).unwrap();
|
let commit = keychain.commit(value, &key_id).unwrap();
|
||||||
let proof = keychain
|
let proof = keychain.range_proof(value, &key_id, commit, None).unwrap();
|
||||||
.range_proof(
|
|
||||||
value,
|
|
||||||
&key_id,
|
|
||||||
commit,
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
transaction::Output {
|
transaction::Output {
|
||||||
features: transaction::OutputFeatures::DEFAULT_OUTPUT,
|
features: transaction::OutputFeatures::DEFAULT_OUTPUT,
|
||||||
|
@ -1732,14 +1725,7 @@ mod tests {
|
||||||
let keychain = keychain_for_tests();
|
let keychain = keychain_for_tests();
|
||||||
let key_id = keychain.derive_key_id(value as u32).unwrap();
|
let key_id = keychain.derive_key_id(value as u32).unwrap();
|
||||||
let commit = keychain.commit(value, &key_id).unwrap();
|
let commit = keychain.commit(value, &key_id).unwrap();
|
||||||
let proof = keychain
|
let proof = keychain.range_proof(value, &key_id, commit, None).unwrap();
|
||||||
.range_proof(
|
|
||||||
value,
|
|
||||||
&key_id,
|
|
||||||
commit,
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
transaction::Output {
|
transaction::Output {
|
||||||
features: transaction::OutputFeatures::COINBASE_OUTPUT,
|
features: transaction::OutputFeatures::COINBASE_OUTPUT,
|
||||||
|
|
Loading…
Reference in a new issue