Fix handling of Monero daemon connections when using an authenticated RPC

The lack of locking the connection when making an authenticated request, which
is actually two sequential requests, risked another caller making a request in
between, invalidating the state.

Now, only unauthenticated connections share a connection object.
This commit is contained in:
Luke Parker
2023-10-26 12:45:39 -04:00
parent f22aedc007
commit 3069138475
3 changed files with 35 additions and 14 deletions

View File

@@ -89,6 +89,7 @@ mod monero {
"--no-zmq".to_string(),
"--disable-rpc-ban".to_string(),
"--rpc-bind-ip=0.0.0.0".to_string(),
"--rpc-login=serai:seraidex".to_string(),
"--rpc-access-control-origins=*".to_string(),
"--confirm-external-bind".to_string(),
"--non-interactive".to_string(),
@@ -110,7 +111,7 @@ mod monero {
let handle = ops.handle("serai-dev-monero").host_port(18081).unwrap();
// TODO: Replace with a check if the node has booted
tokio::time::sleep(core::time::Duration::from_secs(20)).await;
let monero = Monero::new(format!("http://{}:{}", handle.0, handle.1));
let monero = Monero::new(format!("http://serai:seraidex@{}:{}", handle.0, handle.1));
while monero.get_latest_block_number().await.unwrap() < 150 {
monero.mine_block().await;
}