mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-22 17:19:07 -05:00
refactor: clippy suggestions
This commit is contained in:
parent
29effaae23
commit
8137b6211c
20
src/db.rs
20
src/db.rs
|
@ -102,11 +102,11 @@ pub fn optimize_db(conn: &mut PooledConnection) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum SqliteReturnStatus {
|
enum SqliteStatus {
|
||||||
SqliteOk,
|
Ok,
|
||||||
SqliteBusy,
|
Busy,
|
||||||
SqliteError,
|
Error,
|
||||||
SqliteOther(u64),
|
Other(u64),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checkpoint/Truncate WAL
|
/// Checkpoint/Truncate WAL
|
||||||
|
@ -120,10 +120,10 @@ pub fn checkpoint_db(conn: &mut PooledConnection) -> Result<()> {
|
||||||
Ok((checkpoint_result, wal_size, frames_checkpointed))
|
Ok((checkpoint_result, wal_size, frames_checkpointed))
|
||||||
})?;
|
})?;
|
||||||
let result = match cp_result {
|
let result = match cp_result {
|
||||||
0 => SqliteReturnStatus::SqliteOk,
|
0 => SqliteStatus::Ok,
|
||||||
1 => SqliteReturnStatus::SqliteBusy,
|
1 => SqliteStatus::Busy,
|
||||||
2 => SqliteReturnStatus::SqliteError,
|
2 => SqliteStatus::Error,
|
||||||
x => SqliteReturnStatus::SqliteOther(x),
|
x => SqliteStatus::Other(x),
|
||||||
};
|
};
|
||||||
info!(
|
info!(
|
||||||
"checkpoint ran in {:?} (result: {:?}, WAL size: {})",
|
"checkpoint ran in {:?} (result: {:?}, WAL size: {})",
|
||||||
|
@ -770,7 +770,7 @@ pub async fn db_query(
|
||||||
}
|
}
|
||||||
// logging for slow queries; show sub and SQL.
|
// logging for slow queries; show sub and SQL.
|
||||||
// to reduce logging; only show 1/16th of clients (leading 0)
|
// to reduce logging; only show 1/16th of clients (leading 0)
|
||||||
if row_count == 0 && slow_first_event && client_id.starts_with("0") {
|
if row_count == 0 && slow_first_event && client_id.starts_with('0') {
|
||||||
debug!(
|
debug!(
|
||||||
"query req (slow): {:?} (cid: {}, sub: {:?})",
|
"query req (slow): {:?} (cid: {}, sub: {:?})",
|
||||||
sub, client_id, sub.id
|
sub, client_id, sub.id
|
||||||
|
|
|
@ -505,8 +505,10 @@ async fn nostr_server(
|
||||||
let mut client_published_event_count: usize = 0;
|
let mut client_published_event_count: usize = 0;
|
||||||
let mut client_received_event_count: usize = 0;
|
let mut client_received_event_count: usize = 0;
|
||||||
debug!("new client connection (cid: {}, ip: {:?})", cid, conn.ip());
|
debug!("new client connection (cid: {}, ip: {:?})", cid, conn.ip());
|
||||||
let origin = client_info.origin.unwrap_or("<unspecified>".into());
|
let origin = client_info.origin.unwrap_or_else(|| "<unspecified>".into());
|
||||||
let user_agent = client_info.user_agent.unwrap_or("<unspecified>".into());
|
let user_agent = client_info
|
||||||
|
.user_agent
|
||||||
|
.unwrap_or_else(|| "<unspecified>".into());
|
||||||
debug!(
|
debug!(
|
||||||
"cid: {}, origin: {:?}, user-agent: {:?}",
|
"cid: {}, origin: {:?}, user-agent: {:?}",
|
||||||
cid, origin, user_agent
|
cid, origin, user_agent
|
||||||
|
|
Loading…
Reference in New Issue
Block a user