|
|
@ -175,24 +175,30 @@ impl Transport {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async fn recv_response(&mut self, output: jsonrpc::Output) -> anyhow::Result<()> {
|
|
|
|
async fn recv_response(&mut self, output: jsonrpc::Output) -> anyhow::Result<()> {
|
|
|
|
match output {
|
|
|
|
let (id, result) = match output {
|
|
|
|
jsonrpc::Output::Success(jsonrpc::Success { id, result, .. }) => {
|
|
|
|
jsonrpc::Output::Success(jsonrpc::Success { id, result, .. }) => {
|
|
|
|
info!("<- {}", result);
|
|
|
|
info!("<- {}", result);
|
|
|
|
|
|
|
|
(id, Ok(result))
|
|
|
|
let tx = self
|
|
|
|
|
|
|
|
.pending_requests
|
|
|
|
|
|
|
|
.remove(&id)
|
|
|
|
|
|
|
|
.expect("pending_request with id not found!");
|
|
|
|
|
|
|
|
tx.send(Ok(result)).await?;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
jsonrpc::Output::Failure(jsonrpc::Failure { id, error, .. }) => {
|
|
|
|
jsonrpc::Output::Failure(jsonrpc::Failure { id, error, .. }) => {
|
|
|
|
let tx = self
|
|
|
|
error!("<- {}", error);
|
|
|
|
.pending_requests
|
|
|
|
(id, Err(error.into()))
|
|
|
|
.remove(&id)
|
|
|
|
|
|
|
|
.expect("pending_request with id not found!");
|
|
|
|
|
|
|
|
tx.send(Err(error.into())).await?;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let tx = self
|
|
|
|
|
|
|
|
.pending_requests
|
|
|
|
|
|
|
|
.remove(&id)
|
|
|
|
|
|
|
|
.expect("pending_request with id not found!");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
match tx.send(result).await {
|
|
|
|
|
|
|
|
Ok(_) => (),
|
|
|
|
|
|
|
|
Err(_) => error!(
|
|
|
|
|
|
|
|
"Tried sending response into a closed channel (id={:?}), original request likely timed out",
|
|
|
|
|
|
|
|
id
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|