Skip to content

Commit

Permalink
fix: change mmproxy to select new monerod on error (#6321)
Browse files Browse the repository at this point in the history
Description
---
Make sure the MMProxy does select a new node on error

Motivation and Context
---
Its possible for the monerod to error out on SSL, but not send back and
error. The MMProxy then gets this error and keeps retrying the node:
```
ERROR Method "getblocktemplate" failed handling request: MonerodRequestFailed(reqwest::Error { kind: Request, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("xmr.grub.net")), port: Some(18089), path: "/json_rpc", query: None, fragment: None }, source: hyper::Error(Connect, Ssl(Error { code: ErrorCode(1), cause: Some(Ssl(ErrorStack([Error { code: 167772294, library: "SSL routines", function: "tls_post_process_server_certificate", reason: "certificate verify failed", file: "ssl/statem/statem_clnt.c", line: 1889 }]))) }, X509VerifyResult { code: 18, error: "self-signed certificate" })) })
```

On Any error the MMProxy will now select a new monerod from the list it
has.
  • Loading branch information
SWvheerden authored May 7, 2024
1 parent 260d046 commit 2a9250b
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions applications/minotari_merge_mining_proxy/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,15 +858,24 @@ impl InnerService {
return Ok(monerod_resp.map(|json| json.to_string().into()));
}

let response = self.get_proxy_response(request, monerod_resp).await?;
debug!(
"Method: {}, MoneroD Status: {}, Proxy Status: {}, Response Time: {}ms",
method_name,
monerod_status,
response.status(),
start.elapsed().as_millis()
);
Ok(response)
match self.get_proxy_response(request, monerod_resp).await {
Ok(response) => {
debug!(
"Method: {}, MoneroD Status: {}, Proxy Status: {}, Response Time: {}ms",
method_name,
monerod_status,
response.status(),
start.elapsed().as_millis()
);
Ok(response)
},
Err(e) => {
// Monero Server encountered a problem processing the request, reset the current monerod server
let mut lock = self.current_monerod_server.write().expect("Write lock should not fail");
*lock = None;
Err(e)
},
}
},
Err(e) => {
// Monero Server encountered a problem processing the request, reset the current monerod server
Expand Down

0 comments on commit 2a9250b

Please sign in to comment.