Compare commits

...

4 Commits

Author SHA1 Message Date
Tommy Verrall 2fa21dc4e9 amend wallet for sandbox link 2025-06-26 17:20:29 +02:00
benedetta davico ef5990658a Merge pull request #5873 from nymtech/wallet/fix-link 2025-06-26 13:26:36 +02:00
benedettadavico 658dec8299 fix the broken link 2025-06-26 12:44:47 +02:00
dynco-nym 447352b8d6 Set busy_timeout in sqlx (#5872)
* Set busy_timeout

* Bump version
2025-06-26 10:44:06 +02:00
7 changed files with 40 additions and 8 deletions
Generated
+1 -1
View File
@@ -6684,7 +6684,7 @@ dependencies = [
[[package]]
name = "nym-node-status-api"
version = "3.1.0"
version = "3.1.1"
dependencies = [
"ammonia",
"anyhow",
@@ -3,7 +3,7 @@
[package]
name = "nym-node-status-api"
version = "3.1.0"
version = "3.1.1"
authors.workspace = true
repository.workspace = true
homepage.workspace = true
@@ -45,6 +45,10 @@ pub(crate) struct Cli {
#[clap(long, env = "DATABASE_URL")]
pub(crate) database_url: String,
#[clap(long, default_value = "5", env = "SQLX_BUSY_TIMEOUT_S")]
#[arg(value_parser = parse_duration)]
pub(crate) sqlx_busy_timeout_s: Duration,
#[clap(
long,
default_value = "300",
@@ -1,10 +1,11 @@
use anyhow::{anyhow, Result};
use sqlx::{
migrate::Migrator,
query,
sqlite::{SqliteAutoVacuum, SqliteConnectOptions, SqliteSynchronous},
ConnectOptions, SqlitePool,
};
use std::str::FromStr;
use std::{str::FromStr, time::Duration};
pub(crate) mod models;
pub(crate) mod queries;
@@ -18,9 +19,10 @@ pub(crate) struct Storage {
}
impl Storage {
pub async fn init(connection_url: String) -> Result<Self> {
pub async fn init(connection_url: String, busy_timeout: Duration) -> Result<Self> {
let connect_options = SqliteConnectOptions::from_str(&connection_url)?
.journal_mode(sqlx::sqlite::SqliteJournalMode::Wal)
.busy_timeout(busy_timeout)
.synchronous(SqliteSynchronous::Normal)
.auto_vacuum(SqliteAutoVacuum::Incremental)
.foreign_keys(true)
@@ -33,6 +35,9 @@ impl Storage {
MIGRATOR.run(&pool).await?;
// aftering setting pragma, check whether it was set successfully
Self::assert_busy_timeout(pool.clone(), busy_timeout.as_secs() as i64).await?;
Ok(Storage { pool })
}
@@ -40,4 +45,27 @@ impl Storage {
pub fn pool_owned(&self) -> DbPool {
self.pool.clone()
}
async fn assert_busy_timeout(pool: DbPool, expected_busy_timeout_s: i64) -> Result<()> {
let mut conn = pool.acquire().await?;
// Sqlite stores this value as miliseconds
// https://www.sqlite.org/pragma.html#pragma_busy_timeout
let busy_timeout_db = query!("PRAGMA busy_timeout;")
.fetch_one(conn.as_mut())
.await?;
let actual_busy_timeout_ms = busy_timeout_db.timeout.unwrap_or(0);
tracing::info!("PRAGMA busy_timeout={}ms", actual_busy_timeout_ms);
let expected_busy_timeout_ms = expected_busy_timeout_s * 1000;
if expected_busy_timeout_ms != actual_busy_timeout_ms {
anyhow::bail!(
"PRAGMA busy_timeout expected: {}ms, actual: {}ms",
expected_busy_timeout_ms,
actual_busy_timeout_ms
);
}
Ok(())
}
}
@@ -31,7 +31,7 @@ async fn main() -> anyhow::Result<()> {
let connection_url = args.database_url.clone();
tracing::debug!("Using config:\n{:#?}", args);
let storage = db::Storage::init(connection_url).await?;
let storage = db::Storage::init(connection_url, args.sqlx_busy_timeout_s).await?;
let db_pool = storage.pool_owned();
// Start the node scraper
+1 -1
View File
@@ -30,7 +30,7 @@ export const urls = (networkName?: Network) =>
}
: {
blockExplorer: `https://${networkName}-blocks.nymtech.net`,
networkExplorer: `https://${networkName}-explorer.nymtech.net`,
networkExplorer: `https://nym.com/${networkName}-explorer`,
};
type TLoginType = 'mnemonic' | 'password';
@@ -4,12 +4,12 @@ import { TauriLink as Link } from 'src/components/TauriLinkWrapper';
import { urls, AppContext } from '../../context/main';
export const NodeStats = ({ mixnodeId }: { mixnodeId?: string }) => {
export const NodeStats = ({ identityKey }: { identityKey?: string }) => {
const { network } = useContext(AppContext);
return (
<Stack spacing={2} sx={{ p: 4 }}>
<Typography>All your node stats are available on the link below</Typography>
<Link href={`${urls(network).networkExplorer}/nodes/${mixnodeId}`} target="_blank" text="Network Explorer" />
<Link href={`${urls(network).networkExplorer}/nodes/${identityKey}`} target="_blank" text="Network Explorer" />
</Stack>
);
};