Skip to content

Commit

Permalink
Made sphinx packet builder more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
jstuczyn committed Nov 9, 2022
1 parent bec341d commit cc8e4a5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/packet/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ impl<'a> SphinxPacketBuilder<'a> {
self
}

pub fn build_packet(
pub fn build_packet<M: AsRef<[u8]>>(
&self,
message: Vec<u8>,
message: M,
route: &[Node],
destination: &Destination,
delays: &[Delay],
Expand All @@ -41,7 +41,8 @@ impl<'a> SphinxPacketBuilder<'a> {
};

// no need to check if plaintext has correct length as this check is already performed in payload encapsulation
let payload = Payload::encapsulate_message(&message, &payload_keys, self.payload_size)?;
let payload =
Payload::encapsulate_message(message.as_ref(), &payload_keys, self.payload_size)?;
Ok(SphinxPacket { header, payload })
}
}
Expand Down

0 comments on commit cc8e4a5

Please sign in to comment.