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

Commit

Permalink
feat: restore aggregate at source
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi authored and dirvine committed Apr 21, 2021
1 parent 39f746a commit 4e86a20
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/agreement/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ pub(crate) enum Proposal {

// Proposal to accumulate the message at the source (that is, our section) and then send it to
// its destination.
// TODO: it seems we might not need this. Consider removing it.
AccumulateAtSrc {
message: Box<PlainMessage>,
proof_chain: SectionChain,
Expand Down
34 changes: 34 additions & 0 deletions src/routing/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,9 @@ impl Core {
proof_chain,
None,
)?
} else if itinerary.aggregate_at_src() {
let proposal = self.create_aggregate_at_src_proposal(itinerary.dst, variant, None)?;
return self.propose(proposal);
} else {
Message::single_src(&self.node, itinerary.dst, variant, None, None)?
};
Expand All @@ -2206,6 +2209,37 @@ impl Core {
Ok(commands)
}

fn create_aggregate_at_src_proposal(
&self,
dst: DstLocation,
variant: Variant,
proof_chain_first_key: Option<&bls::PublicKey>,
) -> Result<Proposal> {
let proof_chain = self.create_proof_chain(&dst, proof_chain_first_key)?;
let dst_key = if let Some(name) = dst.name() {
*self.section_key_by_name(&name)
} else {
// NOTE: `dst` is `Direct`. We use this when we want the message to accumulate at the
// destination and also be handled only there. We only do this if the recipient is in
// our section, so it's OK to use our latest key as the `dst_key`.
*self.section.chain().last_key()
};

let message = PlainMessage {
src: self.section.prefix().name(),
dst,
dst_key,
variant,
};

let proposal = Proposal::AccumulateAtSrc {
message: Box::new(message),
proof_chain,
};
trace!("Created aggregate at source proposal {:?}", proposal);
Ok(proposal)
}

fn send_message_for_dst_accumulation(
&self,
src: XorName,
Expand Down

0 comments on commit 4e86a20

Please sign in to comment.