Skip to content

Commit

Permalink
Make zebra-rpc use the new state ReadRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Mar 15, 2022
1 parent a1eda17 commit 945bf42
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
19 changes: 10 additions & 9 deletions zebra-rpc/src/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ pub struct RpcImpl<Mempool, State, Tip>
where
Mempool: Service<mempool::Request, Response = mempool::Response, Error = BoxError>,
State: Service<
zebra_state::Request,
Response = zebra_state::Response,
zebra_state::ReadRequest,
Response = zebra_state::ReadResponse,
Error = zebra_state::BoxError,
>,
Tip: ChainTip,
Expand All @@ -137,8 +137,8 @@ impl<Mempool, State, Tip> RpcImpl<Mempool, State, Tip>
where
Mempool: Service<mempool::Request, Response = mempool::Response, Error = BoxError>,
State: Service<
zebra_state::Request,
Response = zebra_state::Response,
zebra_state::ReadRequest,
Response = zebra_state::ReadResponse,
Error = zebra_state::BoxError,
>,
Tip: ChainTip + Send + Sync,
Expand Down Expand Up @@ -170,8 +170,8 @@ where
tower::Service<mempool::Request, Response = mempool::Response, Error = BoxError> + 'static,
Mempool::Future: Send,
State: Service<
zebra_state::Request,
Response = zebra_state::Response,
zebra_state::ReadRequest,
Response = zebra_state::ReadResponse,
Error = zebra_state::BoxError,
> + Clone
+ Send
Expand Down Expand Up @@ -257,7 +257,8 @@ where
data: None,
})?;

let request = zebra_state::Request::Block(zebra_state::HashOrHeight::Height(height));
let request =
zebra_state::ReadRequest::Block(zebra_state::HashOrHeight::Height(height));
let response = state
.ready()
.and_then(|service| service.call(request))
Expand All @@ -269,8 +270,8 @@ where
})?;

match response {
zebra_state::Response::Block(Some(block)) => Ok(GetBlock(block.into())),
zebra_state::Response::Block(None) => Err(Error {
zebra_state::ReadResponse::Block(Some(block)) => Ok(GetBlock(block.into())),
zebra_state::ReadResponse::Block(None) => Err(Error {
code: ErrorCode::ServerError(0),
message: "Block not found".to_string(),
data: None,
Expand Down
4 changes: 2 additions & 2 deletions zebra-rpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ impl RpcServer {
+ 'static,
Mempool::Future: Send,
State: Service<
zebra_state::Request,
Response = zebra_state::Response,
zebra_state::ReadRequest,
Response = zebra_state::ReadResponse,
Error = zebra_state::BoxError,
> + Clone
+ Send
Expand Down

0 comments on commit 945bf42

Please sign in to comment.