mirror of
https://github.com/scsibug/nostr-rs-relay.git
synced 2024-11-25 10:09:08 -05:00
refactor: misc clippy suggestions
This commit is contained in:
parent
a98708ba47
commit
bef7ca7e27
|
@ -60,6 +60,10 @@ impl ClientConn {
|
|||
}
|
||||
|
||||
/// Add a new subscription for this connection.
|
||||
/// # Errors
|
||||
///
|
||||
/// Will return `Err` if the client has too many subscriptions, or
|
||||
/// if the provided name is excessively long.
|
||||
pub fn subscribe(&mut self, s: Subscription) -> Result<()> {
|
||||
let k = s.get_id();
|
||||
let sub_id_len = k.len();
|
||||
|
@ -94,7 +98,7 @@ impl ClientConn {
|
|||
}
|
||||
|
||||
/// Remove the subscription for this connection.
|
||||
pub fn unsubscribe(&mut self, c: Close) {
|
||||
pub fn unsubscribe(&mut self, c: &Close) {
|
||||
// TODO: return notice if subscription did not exist.
|
||||
self.subscriptions.remove(&c.id);
|
||||
debug!(
|
||||
|
|
10
src/db.rs
10
src/db.rs
|
@ -13,7 +13,7 @@ use crate::utils::{is_hex, is_lower_hex};
|
|||
use governor::clock::Clock;
|
||||
use governor::{Quota, RateLimiter};
|
||||
use hex;
|
||||
use log::*;
|
||||
use log::{debug, info, trace, warn};
|
||||
use r2d2;
|
||||
use r2d2_sqlite::SqliteConnectionManager;
|
||||
use rusqlite::params;
|
||||
|
@ -39,9 +39,13 @@ pub struct SubmittedEvent {
|
|||
pub const DB_FILE: &str = "nostr.db";
|
||||
|
||||
/// Build a database connection pool.
|
||||
/// # Panics
|
||||
///
|
||||
/// Will panic if the pool could not be created.
|
||||
#[must_use]
|
||||
pub fn build_pool(
|
||||
name: &str,
|
||||
settings: Settings,
|
||||
settings: &Settings,
|
||||
flags: OpenFlags,
|
||||
min_size: u32,
|
||||
max_size: u32,
|
||||
|
@ -98,7 +102,7 @@ pub async fn db_writer(
|
|||
// create a connection pool
|
||||
let pool = build_pool(
|
||||
"event writer",
|
||||
settings.clone(),
|
||||
&settings,
|
||||
OpenFlags::SQLITE_OPEN_READ_WRITE | OpenFlags::SQLITE_OPEN_CREATE,
|
||||
1,
|
||||
4,
|
||||
|
|
|
@ -146,7 +146,7 @@ impl Verifier {
|
|||
// build a database connection for reading and writing.
|
||||
let write_pool = db::build_pool(
|
||||
"nip05 writer",
|
||||
settings.clone(),
|
||||
&settings,
|
||||
rusqlite::OpenFlags::SQLITE_OPEN_READ_WRITE,
|
||||
1, // min conns
|
||||
4, // max conns
|
||||
|
@ -154,7 +154,7 @@ impl Verifier {
|
|||
);
|
||||
let read_pool = db::build_pool(
|
||||
"nip05 reader",
|
||||
settings.clone(),
|
||||
&settings,
|
||||
rusqlite::OpenFlags::SQLITE_OPEN_READ_ONLY,
|
||||
1, // min conns
|
||||
8, // max conns
|
||||
|
|
|
@ -293,7 +293,7 @@ pub fn start_server(settings: Settings, shutdown_rx: MpscReceiver<()>) -> Result
|
|||
// build a connection pool for sqlite connections
|
||||
let pool = db::build_pool(
|
||||
"client query",
|
||||
settings.clone(),
|
||||
&settings,
|
||||
rusqlite::OpenFlags::SQLITE_OPEN_READ_ONLY
|
||||
| rusqlite::OpenFlags::SQLITE_OPEN_SHARED_CACHE,
|
||||
db_min_conn,
|
||||
|
@ -579,7 +579,7 @@ async fn nostr_server(
|
|||
}
|
||||
// stop checking new events against
|
||||
// the subscription
|
||||
conn.unsubscribe(c);
|
||||
conn.unsubscribe(&c);
|
||||
},
|
||||
Err(_) => {
|
||||
info!("invalid command ignored");
|
||||
|
|
Loading…
Reference in New Issue
Block a user