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:
Luke Parker
2023-11-06 23:45:39 -05:00
parent c03fb6c71b
commit 56fd11ab8d
14 changed files with 169 additions and 76 deletions

View File

@@ -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;
}