Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2fa21dc4e9 | |||
| ef5990658a | |||
| 658dec8299 | |||
| 447352b8d6 |
Generated
+1
-1
@@ -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,6 +1,6 @@
|
||||
[package]
|
||||
name = "NymWallet"
|
||||
version = "1.2.19"
|
||||
version = "1.2.18"
|
||||
description = "Nym Native Wallet"
|
||||
authors = ["Nym Technologies SA"]
|
||||
license = ""
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
},
|
||||
"productName": "NymWallet",
|
||||
"mainBinaryName": "NymWallet",
|
||||
"version": "1.2.19",
|
||||
"version": "1.2.18",
|
||||
"identifier": "net.nymtech.wallet",
|
||||
"plugins": {
|
||||
"updater": {
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -8,7 +8,7 @@ import { LoadingModal } from 'src/components/Modals/LoadingModal';
|
||||
import { Results } from 'src/components/TestNode/Results';
|
||||
import { ErrorModal } from 'src/components/Modals/ErrorModal';
|
||||
import { PrintResults } from 'src/components/TestNode/PrintResults';
|
||||
import { MAINNET_VALIDATOR_URL } from 'src/constants';
|
||||
import { MAINNET_VALIDATOR_URL, QA_VALIDATOR_URL } from 'src/constants';
|
||||
import { TestStatus } from 'src/components/TestNode/types';
|
||||
import { isMixnode } from 'src/types';
|
||||
|
||||
@@ -63,7 +63,7 @@ export const NodeTestPage = () => {
|
||||
const loadNodeTestClient = useCallback(async () => {
|
||||
try {
|
||||
const nodeTesterId = new Date().toISOString(); // make a new tester id for each session
|
||||
const validator = network === 'MAINNET' ? MAINNET_VALIDATOR_URL : 'https://rpc.nymtech.net/api/';
|
||||
const validator = network === 'MAINNET' ? MAINNET_VALIDATOR_URL : QA_VALIDATOR_URL;
|
||||
const client = await createNodeTesterClient();
|
||||
await client.tester.init(validator, nodeTesterId);
|
||||
setNodeTestClient(client);
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user