Skip to content

Commit

Permalink
move CrdsValue::new
Browse files Browse the repository at this point in the history
  • Loading branch information
behzadnouri committed Nov 7, 2024
1 parent 3bb154c commit c3f49c4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions gossip/src/crds_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ impl CrdsValueLabel {
}

impl CrdsValue {
pub fn new(data: CrdsData, keypair: &Keypair) -> Self {
let bincode_serialized_data = bincode::serialize(&data).unwrap();
let signature = keypair.sign_message(&bincode_serialized_data);
Self { signature, data }
}

#[cfg(test)]
pub(crate) fn new_unsigned(data: CrdsData) -> Self {
Self {
Expand All @@ -103,12 +109,6 @@ impl CrdsValue {
}
}

pub fn new(data: CrdsData, keypair: &Keypair) -> Self {
let bincode_serialized_data = bincode::serialize(&data).unwrap();
let signature = keypair.sign_message(&bincode_serialized_data);
Self { signature, data }
}

/// New random CrdsValue for tests and benchmarks.
pub fn new_rand<R: Rng>(rng: &mut R, keypair: Option<&Keypair>) -> CrdsValue {
match keypair {
Expand Down

0 comments on commit c3f49c4

Please sign in to comment.