Skip to content

Commit

Permalink
Remove async-trait from monero-rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
kayabaNerve committed Sep 13, 2024
1 parent 875c669 commit 6b270bc
Show file tree
Hide file tree
Showing 5 changed files with 730 additions and 653 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion networks/monero/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ workspace = true
[dependencies]
std-shims = { path = "../../../common/std-shims", version = "^0.1.1", default-features = false }

async-trait = { version = "0.1", default-features = false }
thiserror = { version = "1", default-features = false, optional = true }

zeroize = { version = "^1.5", default-features = false, features = ["zeroize_derive"] }
Expand Down
2 changes: 0 additions & 2 deletions networks/monero/rpc/simple-request/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ rustdoc-args = ["--cfg", "docsrs"]
workspace = true

[dependencies]
async-trait = { version = "0.1", default-features = false }

hex = { version = "0.4", default-features = false, features = ["alloc"] }
digest_auth = { version = "0.3", default-features = false }
simple-request = { path = "../../../../common/request", version = "0.1", default-features = false, features = ["tls"] }
Expand Down
18 changes: 11 additions & 7 deletions networks/monero/rpc/simple-request/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
#![doc = include_str!("../README.md")]
#![deny(missing_docs)]

use core::future::Future;
use std::{sync::Arc, io::Read, time::Duration};

use async_trait::async_trait;

use tokio::sync::Mutex;

use digest_auth::{WwwAuthenticateHeader, AuthContext};
Expand Down Expand Up @@ -280,11 +279,16 @@ impl SimpleRequestRpc {
}
}

#[async_trait]
impl Rpc for SimpleRequestRpc {
async fn post(&self, route: &str, body: Vec<u8>) -> Result<Vec<u8>, RpcError> {
tokio::time::timeout(self.request_timeout, self.inner_post(route, body))
.await
.map_err(|e| RpcError::ConnectionError(format!("{e:?}")))?
fn post(
&self,
route: &str,
body: Vec<u8>,
) -> impl Send + Future<Output = Result<Vec<u8>, RpcError>> {
async move {
tokio::time::timeout(self.request_timeout, self.inner_post(route, body))
.await
.map_err(|e| RpcError::ConnectionError(format!("{e:?}")))?
}
}
}
Loading

0 comments on commit 6b270bc

Please sign in to comment.