fix(monero-rpc-pool): Keep tasks alive, display retry rate last 200 ops (#423)

* fix(monero-rpc-pool): Keep background tasks alive, display retry rate last 200 ops

* refactors

* if moneor node is offline, use pool

* refactors
This commit is contained in:
Mohan 2025-06-19 23:08:50 +02:00 committed by GitHub
parent 3cb2d907f9
commit b72925ca18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 147 additions and 116 deletions

View file

@ -64,7 +64,7 @@ export default function MoneroPoolHealthBox() {
size="small"
/>
<Chip
label={`${(100 - overallSuccessRate).toFixed(1)}% Retry Rate`}
label={`${(100 - overallSuccessRate).toFixed(1)}% Retry Rate (last 200 operations)`}
color={
overallSuccessRate > 80
? "success"
@ -182,25 +182,6 @@ export default function MoneroPoolHealthBox() {
additionalContent={
<Box sx={{ display: "flex", flexDirection: "column", gap: 2 }}>
{poolStatus && renderHealthSummary()}
{poolStatus && (
<Box>
<Typography variant="body2" sx={{ mb: 1, fontWeight: "medium" }}>
Health Check Statistics
</Typography>
<Box sx={{ display: "flex", gap: 2, flexWrap: "wrap" }}>
<Typography variant="caption" color="text.secondary">
Successful:{" "}
{poolStatus.successful_health_checks.toLocaleString()}
</Typography>
<Typography variant="caption" color="text.secondary">
Failed:{" "}
{poolStatus.unsuccessful_health_checks.toLocaleString()}
</Typography>
</Box>
</Box>
)}
<Box>{renderTopNodes()}</Box>
</Box>
}

View file

@ -223,21 +223,30 @@ export async function initializeContext() {
const bitcoinNodes =
store.getState().settings.nodes[network][Blockchain.Bitcoin];
// For Monero nodes, get the configured node URL and pool setting
// For Monero nodes, determine whether to use pool or custom node
const useMoneroRpcPool = store.getState().settings.useMoneroRpcPool;
const moneroNodes =
store.getState().settings.nodes[network][Blockchain.Monero];
// Always pass the first configured monero node URL directly without checking availability
// The backend will handle whether to use the pool or the custom node
const moneroNode = moneroNodes.length > 0 ? moneroNodes[0] : null;
const moneroNodeUrl =
store.getState().settings.nodes[network][Blockchain.Monero][0] ?? null;
// Check the state of the Monero node
const isMoneroNodeOnline = await getMoneroNodeStatus(moneroNodeUrl, network);
const moneroNodeConfig =
useMoneroRpcPool || moneroNodeUrl == null || !isMoneroNodeOnline
? { type: "Pool" as const }
: {
type: "SingleNode" as const,
content: {
url: moneroNodeUrl,
},
};
// Initialize Tauri settings
const tauriSettings: TauriSettings = {
electrum_rpc_urls: bitcoinNodes,
monero_node_url: moneroNode,
monero_node_config: moneroNodeConfig,
use_tor: useTor,
use_monero_rpc_pool: useMoneroRpcPool,
};
logger.info("Initializing context with settings", tauriSettings);