Work with directory pre-v2.1

Rebase + point to earlier network client code

Adjust to new Nym API types

Refer to earlier client code

Revert "Rebase + point to earlier network client code"

This reverts commit dd75e7dc0695c25b0883e2f5dd15b7d70165e9e8.

Point to earlier commit
This commit is contained in:
dynco-nym
2024-10-14 16:32:39 +02:00
parent 56c55f6b95
commit e5a29cc76e
10 changed files with 727 additions and 343 deletions
Generated
+708 -320
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -155,6 +155,7 @@ default-members = [
"nym-data-observatory",
"nym-node",
"nym-validator-rewarder",
"nym-node-status-api",
"service-providers/authenticator",
"service-providers/ip-packet-router",
"service-providers/network-requester",
+7 -3
View File
@@ -23,10 +23,14 @@ futures-util = { workspace = true }
moka = { workspace = true, features = ["future"] }
nym-bin-common = { path = "../common/bin-common" }
nym-explorer-client = { path = "../explorer-api/explorer-client" }
nym-network-defaults = { path = "../common/network-defaults" }
nym-validator-client = { path = "../common/client-libs/validator-client" }
# TODO dz: ref before Nym API client changes. Update to latest develop once new Nym API is live
nym-network-defaults = { git = "https://github.com/nymtech/nym", rev = "f86e08866" }
nym-validator-client = { git = "https://github.com/nymtech/nym", rev = "f86e08866" }
# nym-network-defaults = { path = "../common/network-defaults" }
# nym-validator-client = { path = "../common/client-libs/validator-client" }
nym-task = { path = "../common/task" }
nym-node-requests = { path = "../nym-node/nym-node-requests", features = ["openapi"] }
nym-node-requests = { git = "https://github.com/nymtech/nym", rev = "f86e08866" }
# nym-node-requests = { path = "../nym-node/nym-node-requests", features = ["openapi"] }
reqwest = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
-7
View File
@@ -13,9 +13,6 @@ pub(crate) struct Config {
nyxd_addr: Url,
#[serde(default = "Config::default_client_timeout")]
#[serde(deserialize_with = "parse_duration")]
nym_api_client_timeout: Duration,
#[serde(default = "Config::default_client_timeout")]
#[serde(deserialize_with = "parse_duration")]
explorer_client_timeout: Duration,
}
@@ -51,10 +48,6 @@ impl Config {
&self.nyxd_addr
}
pub(crate) fn nym_api_client_timeout(&self) -> Duration {
self.nym_api_client_timeout.to_owned()
}
pub(crate) fn nym_explorer_client_timeout(&self) -> Duration {
self.explorer_client_timeout.to_owned()
}
+3 -6
View File
@@ -19,12 +19,9 @@ pub(crate) struct Storage {
impl Storage {
pub async fn init() -> Result<Self> {
let connection_url = read_env_var(DATABASE_URL_ENV_VAR)?;
let connect_options = {
let connect_options = SqliteConnectOptions::from_str(&connection_url)?;
let mut connect_options = connect_options.create_if_missing(true);
let connect_options = connect_options.disable_statement_logging();
(*connect_options).clone()
};
let connect_options = SqliteConnectOptions::from_str(&connection_url)?
.create_if_missing(true)
.disable_statement_logging();
let pool = sqlx::SqlitePool::connect_with(connect_options)
.await
@@ -143,7 +143,7 @@ pub(crate) async fn get_all_gateways(pool: &DbPool) -> anyhow::Result<Vec<Gatewa
ON gw.gateway_identity_key = gd.gateway_identity_key
ORDER BY gw.gateway_identity_key"#,
)
.fetch(&mut conn)
.fetch(&mut *conn)
.try_collect::<Vec<_>>()
.await?;
+1 -1
View File
@@ -37,7 +37,7 @@ async fn insert_summary(
value,
timestamp
)
.execute(&mut tx)
.execute(&mut *tx)
.await
.map_err(|err| {
tracing::error!("Failed to insert data for {kind}: {err}, aborting transaction",);
@@ -71,7 +71,7 @@ pub(crate) async fn get_all_mixnodes(pool: &DbPool) -> anyhow::Result<Vec<Mixnod
LEFT JOIN mixnode_description md ON mn.mix_id = md.mix_id
ORDER BY mn.mix_id"#
)
.fetch(&mut conn)
.fetch(&mut *conn)
.try_collect::<Vec<_>>()
.await?;
@@ -115,7 +115,7 @@ pub(crate) async fn get_daily_stats(pool: &DbPool) -> anyhow::Result<Vec<DailySt
ORDER BY date_utc
"#
)
.fetch(&mut conn)
.fetch(&mut *conn)
.try_collect::<Vec<DailyStats>>()
.await?;
@@ -37,7 +37,7 @@ pub(crate) async fn get_summary_history(pool: &DbPool) -> anyhow::Result<Vec<Sum
ORDER BY date DESC
LIMIT 30"#,
)
.fetch(&mut conn)
.fetch(&mut *conn)
.try_collect::<Vec<_>>()
.await?;
@@ -62,7 +62,7 @@ async fn get_summary_dto(pool: &DbPool) -> anyhow::Result<Vec<SummaryDto>> {
last_updated_utc as "last_updated_utc!"
FROM summary"#
)
.fetch(&mut conn)
.fetch(&mut *conn)
.try_collect::<Vec<_>>()
.await?)
}
+2 -1
View File
@@ -81,7 +81,8 @@ async fn run(
tracing::debug!("6");
let api_client =
NymApiClient::new_with_timeout(default_api_url, config.nym_api_client_timeout());
// TODO dz introduce timeout ?
NymApiClient::new(default_api_url);
let gateways = api_client
.get_cached_described_gateways()
.await