diff --git a/zebra-state/src/on_disk.rs b/zebra-state/src/on_disk.rs index 2bfd01ea..ca6de360 100644 --- a/zebra-state/src/on_disk.rs +++ b/zebra-state/src/on_disk.rs @@ -9,7 +9,7 @@ use std::{ pin::Pin, task::{Context, Poll}, }; -use tower::{buffer::Buffer, Service}; +use tower::{buffer::Buffer, util::BoxService, Service}; use tracing::instrument; use zebra_chain::serialization::{SerializationError, ZcashDeserialize, ZcashSerialize}; use zebra_chain::{ @@ -18,6 +18,9 @@ use zebra_chain::{ Network, }; +/// Type alias of our wrapped service +pub type StateService = Buffer, Request>; + #[derive(Clone)] struct SledState { storage: sled::Db, @@ -243,23 +246,6 @@ impl From for BlockQuery { } } -/// Returns a type that implements the `zebra_state::Service` using `sled`. -/// -/// Each `network` has its own separate sled database. -pub fn init( - config: Config, - network: Network, -) -> impl Service< - Request, - Response = Response, - Error = BoxError, - Future = impl Future>, -> + Send - + Clone - + 'static { - Buffer::new(SledState::new(&config, network), 1) -} - type BoxError = Box; // these hacks are necessary to capture spantraces that can be extracted again @@ -275,7 +261,7 @@ struct BoxRealError(BoxError); /// The TracedError wrapper on a type that implements Error #[derive(Debug)] -struct Error(tracing_error::TracedError); +pub struct Error(tracing_error::TracedError); macro_rules! impl_from { ($($src:ty,)*) => {$( @@ -302,3 +288,10 @@ impl Into for Error { BoxError::from(self.0) } } + +/// Returns a type that implements the `zebra_state::Service` using `sled`. +/// +/// Each `network` has its own separate sled database. +pub fn init(config: Config, network: Network) -> StateService { + Buffer::new(BoxService::new(SledState::new(&config, network)), 1) +}