mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Use a single long-lived RPC connection when authenticated
The prior system spawned a new connection per request to enable parallelism, yet kept hitting hyper::IncompleteMessages I couldn't track down. This attempts to resolve those by a long-lived socket. Halves the amount of requests per-authenticated RPC call, and accordingly is likely still better overall. I don't believe this is resolved yet but this is still worth pushing.
This commit is contained in:
@@ -650,7 +650,7 @@ async fn main() {
|
||||
#[cfg(feature = "bitcoin")]
|
||||
NetworkId::Bitcoin => run(db, Bitcoin::new(url).await, coordinator).await,
|
||||
#[cfg(feature = "monero")]
|
||||
NetworkId::Monero => run(db, Monero::new(url), coordinator).await,
|
||||
NetworkId::Monero => run(db, Monero::new(url).await, coordinator).await,
|
||||
_ => panic!("spawning a processor for an unsupported network"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,8 +191,8 @@ fn map_rpc_err(err: RpcError) -> NetworkError {
|
||||
}
|
||||
|
||||
impl Monero {
|
||||
pub fn new(url: String) -> Monero {
|
||||
Monero { rpc: HttpRpc::new(url).unwrap() }
|
||||
pub async fn new(url: String) -> Monero {
|
||||
Monero { rpc: HttpRpc::new(url).await.unwrap() }
|
||||
}
|
||||
|
||||
fn view_pair(spend: EdwardsPoint) -> ViewPair {
|
||||
|
||||
@@ -114,13 +114,15 @@ mod monero {
|
||||
|
||||
async fn monero(ops: &DockerOperations) -> Monero {
|
||||
let handle = ops.handle("serai-dev-monero").host_port(18081).unwrap();
|
||||
let monero = Monero::new(format!("http://serai:seraidex@{}:{}", handle.0, handle.1));
|
||||
let url = format!("http://serai:seraidex@{}:{}", handle.0, handle.1);
|
||||
for _ in 0 .. 60 {
|
||||
if monero.get_latest_block_number().await.is_ok() {
|
||||
if monero_serai::rpc::HttpRpc::new(url.clone()).await.is_ok() {
|
||||
break;
|
||||
}
|
||||
tokio::time::sleep(core::time::Duration::from_secs(1)).await;
|
||||
}
|
||||
|
||||
let monero = Monero::new(url).await;
|
||||
while monero.get_latest_block_number().await.unwrap() < 150 {
|
||||
monero.mine_block().await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user