Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
fix: reduce unneeded lazy messages
Browse files Browse the repository at this point in the history
  • Loading branch information
madadam committed Mar 24, 2021
1 parent 95f14d8 commit 0498f24
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
11 changes: 3 additions & 8 deletions src/routing/approved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,13 +514,7 @@ impl Approved {
content: vote,
proof_share,
};
let message = Message::single_src(
&self.node,
DstLocation::Direct,
variant,
None,
Some(*self.section.chain().last_key()),
)?;
let message = Message::single_src(&self.node, DstLocation::Direct, variant, None, None)?;

Ok(self.send_or_handle(message, recipients))
}
Expand Down Expand Up @@ -1989,6 +1983,7 @@ impl Approved {
) -> Result<Vec<Command>> {
trace!("Send DKGStart for {} to {:?}", elders_info, recipients);

let src_prefix = elders_info.prefix;
let generation = self.section.chain().main_branch_len() as u64;
let dkg_key = DkgKey::new(&elders_info, generation);
let variant = Variant::DKGStart {
Expand All @@ -1997,7 +1992,7 @@ impl Approved {
};

self.send_message_for_dst_accumulation(
self.section.prefix().name(),
src_prefix.name(),
DstLocation::Direct,
variant,
None,
Expand Down
13 changes: 7 additions & 6 deletions src/routing/lazy_messaging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ pub(crate) fn process(
return Ok(actions);
}

let src_key = msg.proof_chain_last_key();
if !src_key
.map(|src_key| network.has_key(src_key))
.unwrap_or(false)
{
send_other_section = true;
if let Ok(src_key) = msg.proof_chain_last_key() {
if !network.has_key(src_key) {
trace!("lazy messaging: src key unknown");
send_other_section = true;
}
}

if let Some(new) = msg.dst_key() {
Expand All @@ -55,6 +54,7 @@ pub(crate) fn process(
.unwrap_or_else(|| section.chain().root_key());

if section.chain().cmp_by_position(new, old) == Ordering::Greater {
trace!("lazy messaging: dst key updated");
actions.vote = Some(Vote::TheirKnowledge {
prefix: *src_prefix,
key: *new,
Expand All @@ -63,6 +63,7 @@ pub(crate) fn process(
}

if new != section.chain().last_key() {
trace!("lazy messaging: dst key outdated");
send_other_section = true;
}
}
Expand Down

0 comments on commit 0498f24

Please sign in to comment.