Skip to content

Commit 298de8d

Browse files
committed
nits
1 parent d64d83c commit 298de8d

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

consensus/src/marshal/ancestry.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
use crate::{types::Height, Block, Heightable};
44
use commonware_cryptography::Digestible;
5-
use commonware_utils::sync::Mutex;
65
use futures::{
76
future::{BoxFuture, OptionFuture},
87
FutureExt, Stream,
@@ -49,16 +48,12 @@ pub struct ErasedBlockProvider<B: Block> {
4948

5049
impl<B: Block> ErasedBlockProvider<B> {
5150
/// Erase a concrete [`BlockProvider`] into a type-erased provider.
52-
///
53-
/// The provider is wrapped in a `Mutex` so that the resulting closure
54-
/// is `Sync` (required by `Arc<dyn Fn + Send + Sync>`). The lock is
55-
/// held only for the duration of `clone()`, never across an await.
56-
pub fn new<M: BlockProvider<Block = B>>(provider: M) -> Self {
57-
let provider = Arc::new(Mutex::new(provider));
51+
pub fn new<M: BlockProvider<Block = B> + Sync>(provider: M) -> Self {
52+
let provider = Arc::new(provider);
5853
Self {
5954
fetch: Arc::new(move |digest| {
60-
let p = provider.lock().clone();
61-
Box::pin(async move { p.fetch_block(digest).await })
55+
let p = provider.as_ref().clone();
56+
Box::pin(p.fetch_block(digest))
6257
}),
6358
}
6459
}
@@ -87,7 +82,7 @@ pub struct AncestorStream<M, B: Block> {
8782
pending: OptionFuture<BoxFuture<'static, Option<B>>>,
8883
}
8984

90-
impl<M, B: Block> AncestorStream<M, B> {
85+
impl<M: Send + Sync, B: Block> AncestorStream<M, B> {
9186
/// Returns a reference to the next block that will be yielded by the
9287
/// stream, without consuming it.
9388
///

0 commit comments

Comments
 (0)