Skip to content

Commit 9150ac2

Browse files
committed
Rename MixingNodeKind for better clarity
1 parent 64d1b10 commit 9150ac2

File tree

5 files changed

+19
-23
lines changed

5 files changed

+19
-23
lines changed

nym-node-status-api/nym-node-status-api/migrations/004_obsolete_fields.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ ALTER TABLE mixnodes DROP COLUMN blacklisted;
22
ALTER TABLE gateways DROP COLUMN blacklisted;
33

44
CREATE TABLE nym_nodes (
5-
id INTEGER PRIMARY KEY AUTOINCREMENT,
6-
node_id INTEGER NOT NULL UNIQUE,
5+
node_id INTEGER PRIMARY KEY,
76
ed25519_identity_pubkey VARCHAR NOT NULL UNIQUE,
87
total_stake INTEGER NOT NULL,
98
ip_addresses TEXT NOT NULL,

nym-node-status-api/nym-node-status-api/src/db/models.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,14 +360,14 @@ impl TryFrom<GatewaySessionsRecord> for http::models::SessionStats {
360360
}
361361
}
362362

363-
pub(crate) enum NodeKind {
363+
pub(crate) enum MixingNodeKind {
364364
LegacyMixnode,
365365
NymNode,
366366
}
367367

368368
pub(crate) struct ScraperNodeInfo {
369369
pub node_id: i64,
370-
pub node_kind: NodeKind,
370+
pub node_kind: MixingNodeKind,
371371
pub hosts: Vec<String>,
372372
pub http_api_port: i64,
373373
}
@@ -409,8 +409,6 @@ pub(crate) struct NymNodeDto {
409409

410410
#[derive(Debug)]
411411
pub(crate) struct NymNodeInsertRecord {
412-
#[allow(dead_code)]
413-
pub id: i64,
414412
pub node_id: i64,
415413
pub ed25519_identity_pubkey: String,
416414
pub total_stake: i64,
@@ -429,7 +427,6 @@ impl NymNodeInsertRecord {
429427
let now = OffsetDateTime::now_utc().to_string();
430428

431429
let record = Self {
432-
id: Default::default(),
433430
node_id: skimmed_node.node_id.into(),
434431
ed25519_identity_pubkey: skimmed_node.ed25519_identity_pubkey.to_base58_string(),
435432
total_stake,

nym-node-status-api/nym-node-status-api/src/db/queries/packet_stats.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
use crate::db::{
2-
models::{NodeKind, NodeStats, ScraperNodeInfo},
2+
models::{MixingNodeKind, NodeStats, ScraperNodeInfo},
33
DbPool,
44
};
55
use anyhow::Result;
66

77
pub(crate) async fn insert_node_packet_stats(
88
pool: &DbPool,
99
node_id: i64,
10-
node_kind: &NodeKind,
10+
node_kind: &MixingNodeKind,
1111
stats: &NodeStats,
1212
timestamp_utc: i64,
1313
) -> Result<()> {
1414
let mut conn = pool.acquire().await?;
1515

1616
match node_kind {
17-
NodeKind::LegacyMixnode => {
17+
MixingNodeKind::LegacyMixnode => {
1818
sqlx::query!(
1919
r#"
2020
INSERT INTO mixnode_packet_stats_raw (
@@ -30,7 +30,7 @@ pub(crate) async fn insert_node_packet_stats(
3030
.execute(&mut *conn)
3131
.await?;
3232
}
33-
NodeKind::NymNode => {
33+
MixingNodeKind::NymNode => {
3434
sqlx::query!(
3535
r#"
3636
INSERT INTO nym_nodes_packet_stats_raw (
@@ -60,7 +60,7 @@ pub(crate) async fn get_raw_node_stats(
6060
let packets = match node.node_kind {
6161
// if no packets are found, it's fine to assume 0 because that's also
6262
// SQL default value if none provided
63-
NodeKind::LegacyMixnode => {
63+
MixingNodeKind::LegacyMixnode => {
6464
sqlx::query_as!(
6565
NodeStats,
6666
r#"
@@ -78,7 +78,7 @@ pub(crate) async fn get_raw_node_stats(
7878
.fetch_optional(&mut *conn)
7979
.await?
8080
}
81-
NodeKind::NymNode => {
81+
MixingNodeKind::NymNode => {
8282
sqlx::query_as!(
8383
NodeStats,
8484
r#"
@@ -110,7 +110,7 @@ pub(crate) async fn insert_daily_node_stats(
110110
let mut conn = pool.acquire().await?;
111111

112112
match node.node_kind {
113-
NodeKind::LegacyMixnode => {
113+
MixingNodeKind::LegacyMixnode => {
114114
let total_stake = sqlx::query_scalar!(
115115
r#"
116116
SELECT
@@ -146,7 +146,7 @@ pub(crate) async fn insert_daily_node_stats(
146146
.execute(&mut *conn)
147147
.await?;
148148
}
149-
NodeKind::NymNode => {
149+
MixingNodeKind::NymNode => {
150150
let total_stake = sqlx::query_scalar!(
151151
r#"
152152
SELECT

nym-node-status-api/nym-node-status-api/src/db/queries/scraper.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
22
db::{
3-
models::{NodeKind, ScraperNodeInfo},
3+
models::{MixingNodeKind, ScraperNodeInfo},
44
queries, DbPool,
55
},
66
mixnet_scraper::helpers::NodeDescriptionResponse,
@@ -17,7 +17,7 @@ pub(crate) async fn get_mixing_nodes_for_scraping(pool: &DbPool) -> Result<Vec<S
1717
.for_each(|node| {
1818
nodes_to_scrape.push(ScraperNodeInfo {
1919
node_id: node.node_id.into(),
20-
node_kind: NodeKind::NymNode,
20+
node_kind: MixingNodeKind::NymNode,
2121
hosts: node
2222
.ip_addresses
2323
.into_iter()
@@ -64,7 +64,7 @@ pub(crate) async fn get_mixing_nodes_for_scraping(pool: &DbPool) -> Result<Vec<S
6464
{
6565
nodes_to_scrape.push(ScraperNodeInfo {
6666
node_id: mixnode.node_id,
67-
node_kind: NodeKind::LegacyMixnode,
67+
node_kind: MixingNodeKind::LegacyMixnode,
6868
hosts: vec![mixnode.host],
6969
http_api_port: mixnode.http_api_port,
7070
})
@@ -89,15 +89,15 @@ pub(crate) async fn get_mixing_nodes_for_scraping(pool: &DbPool) -> Result<Vec<S
8989

9090
pub(crate) async fn insert_scraped_node_description(
9191
pool: &DbPool,
92-
node_kind: &NodeKind,
92+
node_kind: &MixingNodeKind,
9393
node_id: i64,
9494
description: &NodeDescriptionResponse,
9595
) -> Result<()> {
9696
let timestamp = Utc::now().timestamp();
9797
let mut conn = pool.acquire().await?;
9898

9999
match node_kind {
100-
NodeKind::LegacyMixnode => {
100+
MixingNodeKind::LegacyMixnode => {
101101
sqlx::query!(
102102
r#"
103103
INSERT INTO mixnode_description (
@@ -120,7 +120,7 @@ pub(crate) async fn insert_scraped_node_description(
120120
.execute(&mut *conn)
121121
.await?;
122122
}
123-
NodeKind::NymNode => {
123+
MixingNodeKind::NymNode => {
124124
sqlx::query!(
125125
r#"
126126
INSERT INTO nym_node_descriptions (

nym-node-status-api/nym-node-status-api/src/mixnet_scraper/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl Scraper {
6969
});
7070
}
7171

72-
#[instrument(level = "debug", name = "description_scraper", skip_all)]
72+
#[instrument(level = "info", name = "description_scraper", skip_all)]
7373
async fn run_description_scraper(
7474
pool: &SqlitePool,
7575
queue: Arc<Mutex<Vec<ScraperNodeInfo>>>,
@@ -86,7 +86,7 @@ impl Scraper {
8686
Ok(())
8787
}
8888

89-
#[instrument(level = "debug", name = "packet_scraper", skip_all)]
89+
#[instrument(level = "info", name = "packet_scraper", skip_all)]
9090
async fn run_packet_scraper(
9191
pool: &SqlitePool,
9292
queue: Arc<Mutex<Vec<ScraperNodeInfo>>>,

0 commit comments

Comments
 (0)