Skip to content

Commit 01e9e8a

Browse files
committed
Rename structs to remove module's name
To follow this convention RFC: rust-lang/rfcs#356
1 parent cf809ee commit 01e9e8a

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

zebra-consensus/src/verify.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
//! verification.
55
66
mod block;
7-
mod redjubjub;
7+
pub mod redjubjub;
88
mod script;
99
mod transaction;
1010

11-
pub use self::redjubjub::{RedJubjubItem, RedJubjubVerifier};
1211
pub use block::init;

zebra-consensus/src/verify/redjubjub.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Async RedJubjub batch verifier service
2+
13
use std::{
24
future::Future,
35
mem,
@@ -6,13 +8,13 @@ use std::{
68
};
79

810
use rand::thread_rng;
9-
use redjubjub::*;
11+
use redjubjub::{batch, *};
1012
use tokio::sync::broadcast::{channel, RecvError, Sender};
1113
use tower::Service;
1214
use tower_batch::BatchControl;
1315

1416
/// RedJubjub signature verifier service
15-
pub struct RedJubjubVerifier {
17+
pub struct Verifier {
1618
batch: batch::Verifier,
1719
// This uses a "broadcast" channel, which is an mpmc channel. Tokio also
1820
// provides a spmc channel, "watch", but it only keeps the latest value, so
@@ -22,7 +24,7 @@ pub struct RedJubjubVerifier {
2224
}
2325

2426
#[allow(clippy::new_without_default)]
25-
impl RedJubjubVerifier {
27+
impl Verifier {
2628
/// Create a new RedJubjubVerifier instance
2729
pub fn new() -> Self {
2830
let batch = batch::Verifier::default();
@@ -33,9 +35,9 @@ impl RedJubjubVerifier {
3335
}
3436

3537
/// Type alias to clarify that this batch::Item is a RedJubjubItem
36-
pub type RedJubjubItem = batch::Item;
38+
pub type Item = batch::Item;
3739

38-
impl Service<BatchControl<RedJubjubItem>> for RedJubjubVerifier {
40+
impl Service<BatchControl<Item>> for Verifier {
3941
type Response = ();
4042
type Error = Error;
4143
type Future = Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'static>>;
@@ -44,7 +46,7 @@ impl Service<BatchControl<RedJubjubItem>> for RedJubjubVerifier {
4446
Poll::Ready(Ok(()))
4547
}
4648

47-
fn call(&mut self, req: BatchControl<RedJubjubItem>) -> Self::Future {
49+
fn call(&mut self, req: BatchControl<Item>) -> Self::Future {
4850
match req {
4951
BatchControl::Item(item) => {
5052
tracing::trace!("got item");
@@ -74,7 +76,7 @@ impl Service<BatchControl<RedJubjubItem>> for RedJubjubVerifier {
7476
}
7577
}
7678

77-
impl Drop for RedJubjubVerifier {
79+
impl Drop for Verifier {
7880
fn drop(&mut self) {
7981
// We need to flush the current batch in case there are still any pending futures.
8082
let batch = mem::take(&mut self.batch);
@@ -95,7 +97,7 @@ mod tests {
9597

9698
async fn sign_and_verify<V>(mut verifier: V, n: usize) -> Result<(), V::Error>
9799
where
98-
V: Service<RedJubjubItem, Response = ()>,
100+
V: Service<Item, Response = ()>,
99101
{
100102
let rng = thread_rng();
101103
let mut results = FuturesUnordered::new();
@@ -136,7 +138,7 @@ mod tests {
136138

137139
// Use a very long max_latency and a short timeout to check that
138140
// flushing is happening based on hitting max_items.
139-
let verifier = Batch::new(RedJubjubVerifier::new(), 10, Duration::from_secs(1000));
141+
let verifier = Batch::new(Verifier::new(), 10, Duration::from_secs(1000));
140142
timeout(Duration::from_secs(5), sign_and_verify(verifier, 100)).await?
141143
}
142144

@@ -147,7 +149,7 @@ mod tests {
147149

148150
// Use a very high max_items and a short timeout to check that
149151
// flushing is happening based on hitting max_latency.
150-
let verifier = Batch::new(RedJubjubVerifier::new(), 100, Duration::from_millis(500));
152+
let verifier = Batch::new(Verifier::new(), 100, Duration::from_millis(500));
151153
timeout(Duration::from_secs(5), sign_and_verify(verifier, 10)).await?
152154
}
153155
}

0 commit comments

Comments
 (0)