use tokio::sync::oneshot::error::RecvError;
use crate::BoxError;
pub mod ed25519;
pub mod groth16;
pub mod halo2;
pub mod redjubjub;
pub mod redpallas;
const MAX_BATCH_SIZE: usize = 64;
const MAX_BATCH_LATENCY: std::time::Duration = std::time::Duration::from_millis(100);
pub async fn spawn_fifo_and_convert<
E: 'static + std::error::Error + Into<BoxError> + Sync + Send,
F: 'static + FnOnce() -> Result<(), E> + Send,
>(
f: F,
) -> Result<(), BoxError> {
spawn_fifo(f)
.await
.map_err(|_| {
"threadpool unexpectedly dropped response channel sender. Is Zebra shutting down?"
})?
.map_err(BoxError::from)
}
pub async fn spawn_fifo<
E: 'static + std::error::Error + Sync + Send,
F: 'static + FnOnce() -> Result<(), E> + Send,
>(
f: F,
) -> Result<Result<(), E>, RecvError> {
let (rsp_tx, rsp_rx) = tokio::sync::oneshot::channel();
rayon::spawn_fifo(move || {
let _ = rsp_tx.send(f());
});
rsp_rx.await
}