Skip to content

Commit

Permalink
Update function name to ensure_transmission_is_well_formed
Browse files Browse the repository at this point in the history
  • Loading branch information
raychu86 committed Mar 3, 2024
1 parent c414dbf commit f8c2827
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions node/bft/ledger-service/src/ledger.rs
Expand Up @@ -191,8 +191,8 @@ impl<N: Network, C: ConsensusStorage<N>> LedgerService<N> for CoreLedgerService<
}
}

/// Ensures the given transmission ID matches the given transmission.
fn ensure_transmission_id_matches(
/// Ensures that the given transmission is not a fee and matches the given transmission ID.
fn ensure_transmission_is_well_formed(
&self,
transmission_id: TransmissionID<N>,
transmission: &mut Transmission<N>,
Expand Down
4 changes: 2 additions & 2 deletions node/bft/ledger-service/src/mock.rs
Expand Up @@ -143,8 +143,8 @@ impl<N: Network> LedgerService<N> for MockLedgerService<N> {
Ok(false)
}

/// Ensures the given transmission ID matches the given transmission.
fn ensure_transmission_id_matches(
/// Ensures that the given transmission is not a fee and matches the given transmission ID.
fn ensure_transmission_is_well_formed(
&self,
transmission_id: TransmissionID<N>,
_transmission: &mut Transmission<N>,
Expand Down
4 changes: 2 additions & 2 deletions node/bft/ledger-service/src/prover.rs
Expand Up @@ -124,8 +124,8 @@ impl<N: Network> LedgerService<N> for ProverLedgerService<N> {
bail!("Transmission '{transmission_id}' does not exist in prover")
}

/// Ensures the given transmission ID matches the given transmission.
fn ensure_transmission_id_matches(
/// Ensures that the given transmission is not a fee and matches the given transmission ID.
fn ensure_transmission_is_well_formed(
&self,
_transmission_id: TransmissionID<N>,
_transmission: &mut Transmission<N>,
Expand Down
4 changes: 2 additions & 2 deletions node/bft/ledger-service/src/traits.rs
Expand Up @@ -78,8 +78,8 @@ pub trait LedgerService<N: Network>: Debug + Send + Sync {
/// Returns `true` if the ledger contains the given transmission ID.
fn contains_transmission(&self, transmission_id: &TransmissionID<N>) -> Result<bool>;

/// Ensures the given transmission ID matches the given transmission.
fn ensure_transmission_id_matches(
/// Ensures that the given transmission is not a fee and matches the given transmission ID.
fn ensure_transmission_is_well_formed(
&self,
transmission_id: TransmissionID<N>,
transmission: &mut Transmission<N>,
Expand Down
2 changes: 1 addition & 1 deletion node/bft/ledger-service/src/translucent.rs
Expand Up @@ -135,7 +135,7 @@ impl<N: Network, C: ConsensusStorage<N>> LedgerService<N> for TranslucentLedgerS
}

/// Always succeeds.
fn ensure_transmission_id_matches(
fn ensure_transmission_is_well_formed(
&self,
_transmission_id: TransmissionID<N>,
_transmission: &mut Transmission<N>,
Expand Down
4 changes: 2 additions & 2 deletions node/bft/src/primary.rs
Expand Up @@ -573,8 +573,8 @@ impl<N: Network> Primary<N> {

// Check that the transmission ids match and are not fee transactions.
for (transmission_id, transmission) in transmissions.iter_mut() {
// If the transmission is invalid, then return early.
if let Err(err) = self.ledger.ensure_transmission_id_matches(*transmission_id, transmission) {
// If the transmission is not well-formed, then return early.
if let Err(err) = self.ledger.ensure_transmission_is_well_formed(*transmission_id, transmission) {
debug!("Batch propose from '{peer_ip}' contains an invalid transmission - {err}",);
return Ok(());
}
Expand Down
8 changes: 4 additions & 4 deletions node/bft/src/worker.rs
Expand Up @@ -428,8 +428,8 @@ impl<N: Network> Worker<N> {
let exists = self.pending.get(transmission_id).unwrap_or_default().contains(&peer_ip);
// If the peer IP exists, finish the pending request.
if exists {
// Ensure the transmission ID matches the transmission.
match self.ledger.ensure_transmission_id_matches(transmission_id, &mut transmission) {
// Ensure the transmission is not a fee and matches the transmission ID.
match self.ledger.ensure_transmission_is_well_formed(transmission_id, &mut transmission) {
Ok(()) => {
// Remove the transmission ID from the pending queue.
self.pending.remove(transmission_id, Some(transmission));
Expand Down Expand Up @@ -516,7 +516,7 @@ mod tests {
fn get_committee_lookback_for_round(&self, round: u64) -> Result<Committee<N>>;
fn contains_certificate(&self, certificate_id: &Field<N>) -> Result<bool>;
fn contains_transmission(&self, transmission_id: &TransmissionID<N>) -> Result<bool>;
fn ensure_transmission_id_matches(
fn ensure_transmission_is_well_formed(
&self,
transmission_id: TransmissionID<N>,
transmission: &mut Transmission<N>,
Expand Down Expand Up @@ -609,7 +609,7 @@ mod tests {
let mut mock_ledger = MockLedger::default();
mock_ledger.expect_current_committee().returning(move || Ok(committee.clone()));
mock_ledger.expect_get_committee_lookback_for_round().returning(move |_| Ok(committee_clone.clone()));
mock_ledger.expect_ensure_transmission_id_matches().returning(|_, _| Ok(()));
mock_ledger.expect_ensure_transmission_is_well_formed().returning(|_, _| Ok(()));
let ledger: Arc<dyn LedgerService<CurrentNetwork>> = Arc::new(mock_ledger);
// Initialize the storage.
let storage = Storage::<CurrentNetwork>::new(ledger.clone(), Arc::new(BFTMemoryService::new()), 1);
Expand Down

0 comments on commit f8c2827

Please sign in to comment.