mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Make simple_request::Client generic to the executor
Part of https://github.com/serai-dex/serai/issues/682. We don't remove the use of `tokio::sync::Mutex` now as `hyper` pulls in `tokio::sync` anyways, so there's no point in replacing it. This doesn't yet solve TLS for non-`tokio` `Client`s.
This commit is contained in:
52
Cargo.lock
generated
52
Cargo.lock
generated
@@ -544,7 +544,7 @@ dependencies = [
|
||||
"alloy-json-rpc",
|
||||
"alloy-transport",
|
||||
"serde_json",
|
||||
"simple-request",
|
||||
"simple-request 0.3.0",
|
||||
"tower 0.5.2",
|
||||
]
|
||||
|
||||
@@ -1461,7 +1461,7 @@ dependencies = [
|
||||
"secp256k1 0.29.1",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"simple-request",
|
||||
"simple-request 0.3.0",
|
||||
"std-shims 0.1.5",
|
||||
"subtle",
|
||||
"thiserror 2.0.16",
|
||||
@@ -6122,7 +6122,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "monero-address"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=4b7191e3da20e42f839bfd6d706f75364004a4b8#4b7191e3da20e42f839bfd6d706f75364004a4b8"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"monero-base58",
|
||||
@@ -6134,7 +6134,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "monero-base58"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=4b7191e3da20e42f839bfd6d706f75364004a4b8#4b7191e3da20e42f839bfd6d706f75364004a4b8"
|
||||
dependencies = [
|
||||
"monero-primitives",
|
||||
"std-shims 0.1.99",
|
||||
@@ -6143,7 +6143,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "monero-borromean"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=4b7191e3da20e42f839bfd6d706f75364004a4b8#4b7191e3da20e42f839bfd6d706f75364004a4b8"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"monero-generators",
|
||||
@@ -6156,7 +6156,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "monero-bulletproofs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=4b7191e3da20e42f839bfd6d706f75364004a4b8#4b7191e3da20e42f839bfd6d706f75364004a4b8"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"monero-generators",
|
||||
@@ -6171,7 +6171,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "monero-clsag"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=4b7191e3da20e42f839bfd6d706f75364004a4b8#4b7191e3da20e42f839bfd6d706f75364004a4b8"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"dalek-ff-group 0.5.99",
|
||||
@@ -6192,11 +6192,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "monero-daemon-rpc"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=4b7191e3da20e42f839bfd6d706f75364004a4b8#4b7191e3da20e42f839bfd6d706f75364004a4b8"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"hex",
|
||||
"monero-address",
|
||||
"monero-epee",
|
||||
"monero-interface",
|
||||
"monero-oxide",
|
||||
"serde",
|
||||
@@ -6204,10 +6205,15 @@ dependencies = [
|
||||
"std-shims 0.1.99",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "monero-epee"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/kayabaNerve/monero-oxide?rev=769ea96433ba57a22445bc71a2859f6dec4f60cc#769ea96433ba57a22445bc71a2859f6dec4f60cc"
|
||||
|
||||
[[package]]
|
||||
name = "monero-generators"
|
||||
version = "0.4.0"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=4b7191e3da20e42f839bfd6d706f75364004a4b8#4b7191e3da20e42f839bfd6d706f75364004a4b8"
|
||||
dependencies = [
|
||||
"crypto-bigint 0.5.5",
|
||||
"curve25519-dalek",
|
||||
@@ -6222,7 +6228,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "monero-interface"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=4b7191e3da20e42f839bfd6d706f75364004a4b8#4b7191e3da20e42f839bfd6d706f75364004a4b8"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"hex",
|
||||
@@ -6235,7 +6241,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "monero-io"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=4b7191e3da20e42f839bfd6d706f75364004a4b8#4b7191e3da20e42f839bfd6d706f75364004a4b8"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"std-shims 0.1.99",
|
||||
@@ -6245,7 +6251,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "monero-mlsag"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=4b7191e3da20e42f839bfd6d706f75364004a4b8#4b7191e3da20e42f839bfd6d706f75364004a4b8"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"monero-generators",
|
||||
@@ -6259,7 +6265,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "monero-oxide"
|
||||
version = "0.1.4-alpha"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=4b7191e3da20e42f839bfd6d706f75364004a4b8#4b7191e3da20e42f839bfd6d706f75364004a4b8"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"hex-literal",
|
||||
@@ -6277,7 +6283,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "monero-primitives"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=4b7191e3da20e42f839bfd6d706f75364004a4b8#4b7191e3da20e42f839bfd6d706f75364004a4b8"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"monero-generators",
|
||||
@@ -6290,12 +6296,12 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "monero-simple-request-rpc"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=4b7191e3da20e42f839bfd6d706f75364004a4b8#4b7191e3da20e42f839bfd6d706f75364004a4b8"
|
||||
dependencies = [
|
||||
"digest_auth",
|
||||
"hex",
|
||||
"monero-daemon-rpc",
|
||||
"simple-request",
|
||||
"simple-request 0.2.99",
|
||||
"tokio",
|
||||
"zeroize",
|
||||
]
|
||||
@@ -6303,7 +6309,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "monero-wallet"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c#f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c"
|
||||
source = "git+https://github.com/monero-oxide/monero-oxide?rev=4b7191e3da20e42f839bfd6d706f75364004a4b8#4b7191e3da20e42f839bfd6d706f75364004a4b8"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"flexible-transcript",
|
||||
@@ -9793,7 +9799,7 @@ dependencies = [
|
||||
"serai-docker-tests",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"simple-request",
|
||||
"simple-request 0.3.0",
|
||||
"sp-core",
|
||||
"sp-runtime",
|
||||
"thiserror 2.0.16",
|
||||
@@ -11066,7 +11072,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "simple-request"
|
||||
version = "0.2.0"
|
||||
version = "0.2.99"
|
||||
dependencies = [
|
||||
"hyper-util",
|
||||
"simple-request 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simple-request"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
"futures-util",
|
||||
|
||||
@@ -187,7 +187,7 @@ overflow-checks = true
|
||||
[patch.crates-io]
|
||||
# Dependencies from monero-oxide which originate from within our own tree
|
||||
std-shims = { path = "patches/std-shims" }
|
||||
simple-request = { path = "common/request" }
|
||||
simple-request = { path = "patches/simple-request" }
|
||||
multiexp = { path = "crypto/multiexp" }
|
||||
flexible-transcript = { path = "crypto/transcript" }
|
||||
ciphersuite = { path = "patches/ciphersuite" }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "simple-request"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
description = "A simple HTTP(S) request library"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/serai-dex/serai/tree/develop/common/request"
|
||||
@@ -19,10 +19,10 @@ workspace = true
|
||||
[dependencies]
|
||||
tower-service = { version = "0.3", default-features = false }
|
||||
hyper = { version = "1", default-features = false, features = ["http1", "client"] }
|
||||
hyper-util = { version = "0.1", default-features = false, features = ["http1", "client-legacy", "tokio"] }
|
||||
hyper-util = { version = "0.1", default-features = false, features = ["http1", "client-legacy"] }
|
||||
http-body-util = { version = "0.1", default-features = false }
|
||||
futures-util = { version = "0.3", default-features = false, features = ["std"] }
|
||||
tokio = { version = "1", default-features = false }
|
||||
tokio = { version = "1", default-features = false, features = ["sync"] }
|
||||
|
||||
hyper-rustls = { version = "0.27", default-features = false, features = ["http1", "ring", "rustls-native-certs", "native-tokio"], optional = true }
|
||||
|
||||
@@ -30,7 +30,8 @@ zeroize = { version = "1", optional = true }
|
||||
base64ct = { version = "1", features = ["alloc"], optional = true }
|
||||
|
||||
[features]
|
||||
tls = ["hyper-rustls"]
|
||||
tokio = ["hyper-util/tokio"]
|
||||
tls = ["tokio", "hyper-rustls"]
|
||||
webpki-roots = ["tls", "hyper-rustls/webpki-roots"]
|
||||
basic-auth = ["zeroize", "base64ct"]
|
||||
default = ["tls"]
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
||||
#![doc = include_str!("../README.md")]
|
||||
|
||||
use core::{pin::Pin, future::Future};
|
||||
use std::sync::Arc;
|
||||
|
||||
use tokio::sync::Mutex;
|
||||
use futures_util::FutureExt;
|
||||
use ::tokio::sync::Mutex;
|
||||
|
||||
use tower_service::Service as TowerService;
|
||||
use hyper::{Uri, header::HeaderValue, body::Bytes, client::conn::http1::SendRequest, rt::Executor};
|
||||
pub use hyper;
|
||||
|
||||
use hyper_util::client::legacy::{Client as HyperClient, connect::HttpConnector};
|
||||
|
||||
#[cfg(feature = "tls")]
|
||||
use hyper_rustls::{HttpsConnectorBuilder, HttpsConnector};
|
||||
use hyper::{Uri, header::HeaderValue, body::Bytes, client::conn::http1::SendRequest};
|
||||
use hyper_util::{
|
||||
rt::tokio::TokioExecutor,
|
||||
client::legacy::{Client as HyperClient, connect::HttpConnector},
|
||||
};
|
||||
pub use hyper;
|
||||
|
||||
mod request;
|
||||
pub use request::*;
|
||||
@@ -37,21 +38,32 @@ type Connector = HttpConnector;
|
||||
type Connector = HttpsConnector<HttpConnector>;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
enum Connection {
|
||||
enum Connection<
|
||||
E: 'static + Send + Sync + Clone + Executor<Pin<Box<dyn Send + Future<Output = ()>>>>,
|
||||
> {
|
||||
ConnectionPool(HyperClient<Connector, Full<Bytes>>),
|
||||
Connection {
|
||||
executor: E,
|
||||
connector: Connector,
|
||||
host: Uri,
|
||||
connection: Arc<Mutex<Option<SendRequest<Full<Bytes>>>>>,
|
||||
},
|
||||
}
|
||||
|
||||
/// An HTTP client.
|
||||
///
|
||||
/// `tls` is only guaranteed to work when using the `tokio` executor. Instantiating a client when
|
||||
/// the `tls` feature is active without using the `tokio` executor will cause errors.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Client {
|
||||
connection: Connection,
|
||||
pub struct Client<
|
||||
E: 'static + Send + Sync + Clone + Executor<Pin<Box<dyn Send + Future<Output = ()>>>>,
|
||||
> {
|
||||
connection: Connection<E>,
|
||||
}
|
||||
|
||||
impl Client {
|
||||
impl<E: 'static + Send + Sync + Clone + Executor<Pin<Box<dyn Send + Future<Output = ()>>>>>
|
||||
Client<E>
|
||||
{
|
||||
#[allow(clippy::unnecessary_wraps)]
|
||||
fn connector() -> Result<Connector, Error> {
|
||||
let mut res = HttpConnector::new();
|
||||
@@ -59,6 +71,15 @@ impl Client {
|
||||
res.set_nodelay(true);
|
||||
res.set_reuse_address(true);
|
||||
|
||||
#[cfg(feature = "tls")]
|
||||
if core::any::TypeId::of::<E>() !=
|
||||
core::any::TypeId::of::<hyper_util::rt::tokio::TokioExecutor>()
|
||||
{
|
||||
Err(Error::ConnectionError(
|
||||
"`tls` feature enabled but not using the `tokio` executor".into(),
|
||||
))?;
|
||||
}
|
||||
|
||||
#[cfg(feature = "tls")]
|
||||
res.enforce_http(false);
|
||||
#[cfg(feature = "tls")]
|
||||
@@ -79,19 +100,23 @@ impl Client {
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
pub fn with_connection_pool() -> Result<Client, Error> {
|
||||
pub fn with_executor_and_connection_pool(executor: E) -> Result<Client<E>, Error> {
|
||||
Ok(Client {
|
||||
connection: Connection::ConnectionPool(
|
||||
HyperClient::builder(TokioExecutor::new())
|
||||
HyperClient::builder(executor)
|
||||
.pool_idle_timeout(core::time::Duration::from_secs(60))
|
||||
.build(Self::connector()?),
|
||||
),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn without_connection_pool(host: &str) -> Result<Client, Error> {
|
||||
pub fn with_executor_and_without_connection_pool(
|
||||
executor: E,
|
||||
host: &str,
|
||||
) -> Result<Client<E>, Error> {
|
||||
Ok(Client {
|
||||
connection: Connection::Connection {
|
||||
executor,
|
||||
connector: Self::connector()?,
|
||||
host: {
|
||||
let uri: Uri = host.parse().map_err(|_| Error::InvalidUri)?;
|
||||
@@ -105,7 +130,7 @@ impl Client {
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn request<R: Into<Request>>(&self, request: R) -> Result<Response<'_>, Error> {
|
||||
pub async fn request<R: Into<Request>>(&self, request: R) -> Result<Response<'_, E>, Error> {
|
||||
let request: Request = request.into();
|
||||
let Request { mut request, response_size_limit } = request;
|
||||
if let Some(header_host) = request.headers().get(hyper::header::HOST) {
|
||||
@@ -141,7 +166,7 @@ impl Client {
|
||||
Connection::ConnectionPool(client) => {
|
||||
client.request(request).await.map_err(Error::HyperUtil)?
|
||||
}
|
||||
Connection::Connection { connector, host, connection } => {
|
||||
Connection::Connection { executor, connector, host, connection } => {
|
||||
let mut connection_lock = connection.lock().await;
|
||||
|
||||
// If there's not a connection...
|
||||
@@ -153,9 +178,8 @@ impl Client {
|
||||
let call_res = call_res.map_err(Error::ConnectionError);
|
||||
let (requester, connection) =
|
||||
hyper::client::conn::http1::handshake(call_res?).await.map_err(Error::Hyper)?;
|
||||
// This will die when we drop the requester, so we don't need to track an AbortHandle
|
||||
// for it
|
||||
tokio::spawn(connection);
|
||||
// This task will die when we drop the requester
|
||||
executor.execute(Box::pin(connection.map(|_| ())));
|
||||
*connection_lock = Some(requester);
|
||||
}
|
||||
|
||||
@@ -178,3 +202,22 @@ impl Client {
|
||||
Ok(Response { response, size_limit: response_size_limit, client: self })
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "tokio")]
|
||||
mod tokio {
|
||||
use hyper_util::rt::tokio::TokioExecutor;
|
||||
use super::*;
|
||||
|
||||
pub type TokioClient = Client<TokioExecutor>;
|
||||
impl Client<TokioExecutor> {
|
||||
pub fn with_connection_pool() -> Result<Self, Error> {
|
||||
Self::with_executor_and_connection_pool(TokioExecutor::new())
|
||||
}
|
||||
|
||||
pub fn without_connection_pool(host: &str) -> Result<Self, Error> {
|
||||
Self::with_executor_and_without_connection_pool(TokioExecutor::new(), host)
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "tokio")]
|
||||
pub use tokio::TokioClient;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
use core::{pin::Pin, future::Future};
|
||||
use std::io;
|
||||
|
||||
use hyper::{
|
||||
StatusCode,
|
||||
header::{HeaderValue, HeaderMap},
|
||||
body::Incoming,
|
||||
rt::Executor,
|
||||
};
|
||||
use http_body_util::BodyExt;
|
||||
|
||||
@@ -14,13 +16,18 @@ use crate::{Client, Error};
|
||||
// Borrows the client so its async task lives as long as this response exists.
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
pub struct Response<'a> {
|
||||
pub struct Response<
|
||||
'a,
|
||||
E: 'static + Send + Sync + Clone + Executor<Pin<Box<dyn Send + Future<Output = ()>>>>,
|
||||
> {
|
||||
pub(crate) response: hyper::Response<Incoming>,
|
||||
pub(crate) size_limit: Option<usize>,
|
||||
pub(crate) client: &'a Client,
|
||||
pub(crate) client: &'a Client<E>,
|
||||
}
|
||||
|
||||
impl Response<'_> {
|
||||
impl<E: 'static + Send + Sync + Clone + Executor<Pin<Box<dyn Send + Future<Output = ()>>>>>
|
||||
Response<'_, E>
|
||||
{
|
||||
pub fn status(&self) -> StatusCode {
|
||||
self.response.status()
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ frost = { package = "modular-frost", path = "../../crypto/frost", version = "0.1
|
||||
hex = { version = "0.4", default-features = false, optional = true }
|
||||
serde = { version = "1", default-features = false, features = ["derive"], optional = true }
|
||||
serde_json = { version = "1", default-features = false, optional = true }
|
||||
simple-request = { path = "../../common/request", version = "0.2", default-features = false, features = ["tls", "basic-auth"], optional = true }
|
||||
simple-request = { path = "../../common/request", version = "0.3", default-features = false, features = ["tokio", "tls", "basic-auth"], optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
secp256k1 = { version = "0.29", default-features = false, features = ["std"] }
|
||||
|
||||
@@ -6,7 +6,7 @@ use thiserror::Error;
|
||||
use serde::{Deserialize, de::DeserializeOwned};
|
||||
use serde_json::json;
|
||||
|
||||
use simple_request::{hyper, Request, Client};
|
||||
use simple_request::{hyper, Request, TokioClient as Client};
|
||||
|
||||
use bitcoin::{
|
||||
hashes::{Hash, hex::FromHex},
|
||||
|
||||
@@ -19,7 +19,7 @@ workspace = true
|
||||
tower = "0.5"
|
||||
|
||||
serde_json = { version = "1", default-features = false }
|
||||
simple-request = { path = "../../../common/request", version = "0.2", default-features = false }
|
||||
simple-request = { path = "../../../common/request", version = "0.3", default-features = false, features = ["tokio"] }
|
||||
|
||||
alloy-json-rpc = { version = "1", default-features = false }
|
||||
alloy-transport = { version = "1", default-features = false }
|
||||
|
||||
@@ -7,7 +7,7 @@ use std::io;
|
||||
use alloy_json_rpc::{RequestPacket, ResponsePacket};
|
||||
use alloy_transport::{TransportError, TransportErrorKind, TransportFut};
|
||||
|
||||
use simple_request::{hyper, Error, Request, Client};
|
||||
use simple_request::{hyper, Error, Request, TokioClient as Client};
|
||||
|
||||
use tower::Service;
|
||||
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
[package]
|
||||
name = "simple-request"
|
||||
version = "0.1.99"
|
||||
version = "0.2.99"
|
||||
description = "simple-request which patches to the latest update"
|
||||
license = "MIT"
|
||||
repository = "https://github.com/serai-dex/serai/tree/develop/patches/simple-request"
|
||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||
keywords = ["nostd", "no_std", "alloc", "io"]
|
||||
edition = "2021"
|
||||
rust-version = "1.65"
|
||||
rust-version = "1.71"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
simple-request = { path = "../../common/request" }
|
||||
hyper-util = { version = "0.1", default-features = false, features = ["tokio"] }
|
||||
simple-request = { path = "../../common/request", default-features = false, features = ["tokio"] }
|
||||
|
||||
[features]
|
||||
tls = ["simple-request/tls"]
|
||||
basic-auth = ["simple-request/basic-auth"]
|
||||
|
||||
@@ -1,18 +1,2 @@
|
||||
pub use simple_request::{hyper, Error, Request, Response};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Client(simple_request::Client);
|
||||
|
||||
impl Client {
|
||||
pub fn with_connection_pool() -> Client {
|
||||
Self(simple_request::Client::with_connection_pool().unwrap())
|
||||
}
|
||||
|
||||
pub fn without_connection_pool(host: &str) -> Result<Client, Error> {
|
||||
simple_request::Client::without_connection_pool(host).map(Self)
|
||||
}
|
||||
|
||||
pub async fn request<R: Into<Request>>(&self, request: R) -> Result<Response<'_>, Error> {
|
||||
self.0.request(request).await
|
||||
}
|
||||
}
|
||||
pub use simple_request::{hyper, Error, Request, TokioClient as Client};
|
||||
pub type Response<'a> = simple_request::Response<'a, hyper_util::rt::tokio::TokioExecutor>;
|
||||
|
||||
@@ -29,8 +29,8 @@ dalek-ff-group = { path = "../../crypto/dalek-ff-group", default-features = fals
|
||||
dkg = { package = "dkg-evrf", path = "../../crypto/dkg/evrf", default-features = false, features = ["std", "ed25519"] }
|
||||
frost = { package = "modular-frost", path = "../../crypto/frost", default-features = false }
|
||||
|
||||
monero-wallet = { git = "https://github.com/monero-oxide/monero-oxide", rev = "f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c", default-features = false, features = ["std", "multisig"] }
|
||||
monero-simple-request-rpc = { git = "https://github.com/monero-oxide/monero-oxide", rev = "f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c", default-features = false }
|
||||
monero-wallet = { git = "https://github.com/monero-oxide/monero-oxide", rev = "4b7191e3da20e42f839bfd6d706f75364004a4b8", default-features = false, features = ["std", "multisig"] }
|
||||
monero-simple-request-rpc = { git = "https://github.com/monero-oxide/monero-oxide", rev = "4b7191e3da20e42f839bfd6d706f75364004a4b8", default-features = false }
|
||||
|
||||
serai-client = { path = "../../substrate/client", default-features = false, features = ["monero"] }
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ async fn signable_transaction(
|
||||
RctType::ClsagBulletproofPlus => 16,
|
||||
_ => panic!("selecting decoys for an unsupported RctType"),
|
||||
},
|
||||
reference_block.0.block.number().unwrap() + 1,
|
||||
reference_block.0.block.number() + 1,
|
||||
input.0.clone(),
|
||||
)
|
||||
.await?,
|
||||
|
||||
@@ -37,13 +37,13 @@ frame-system = { git = "https://github.com/serai-dex/substrate", optional = true
|
||||
|
||||
async-lock = "3"
|
||||
|
||||
simple-request = { path = "../../common/request", version = "0.2", optional = true }
|
||||
simple-request = { path = "../../common/request", version = "0.3", features = ["tokio"], optional = true }
|
||||
|
||||
bitcoin = { version = "0.32", optional = true }
|
||||
|
||||
ciphersuite = { path = "../../crypto/ciphersuite", optional = true }
|
||||
dalek-ff-group = { path = "../../crypto/dalek-ff-group", optional = true }
|
||||
monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c", version = "0.1.0", default-features = false, features = ["std"], optional = true }
|
||||
monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "4b7191e3da20e42f839bfd6d706f75364004a4b8", version = "0.1.0", default-features = false, features = ["std"], optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
rand_core = "0.6"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use thiserror::Error;
|
||||
|
||||
use async_lock::RwLock;
|
||||
use simple_request::{hyper, Request, Client};
|
||||
use simple_request::{hyper, Request, TokioClient as Client};
|
||||
|
||||
use scale::{Decode, Encode};
|
||||
use serde::{Serialize, Deserialize, de::DeserializeOwned};
|
||||
|
||||
@@ -82,7 +82,7 @@ serai-env = { path = "../../common/env" }
|
||||
|
||||
curve25519-dalek = { version = "4", default-features = false, features = ["alloc", "zeroize"] }
|
||||
bitcoin-serai = { path = "../../networks/bitcoin", default-features = false, features = ["std", "hazmat"] }
|
||||
monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "f6f4dd7dc5b7c6e057b2eac2ec4980bb7a1c707c", default-features = false, features = ["std"] }
|
||||
monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "4b7191e3da20e42f839bfd6d706f75364004a4b8", default-features = false, features = ["std"] }
|
||||
|
||||
[build-dependencies]
|
||||
substrate-build-script-utils = { git = "https://github.com/serai-dex/substrate" }
|
||||
|
||||
Reference in New Issue
Block a user