chore: clippy

This commit is contained in:
kieran 2024-11-29 16:44:17 +00:00
parent 2370204546
commit 91cf173058
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
8 changed files with 32 additions and 22 deletions

View File

@ -1,5 +1,4 @@
use anyhow::Error; use anyhow::Error;
use chrono::Utc;
use clap::Parser; use clap::Parser;
use config::{Config, File}; use config::{Config, File};
use fedimint_tonic_lnd::connect; use fedimint_tonic_lnd::connect;

View File

@ -69,6 +69,12 @@ struct MempoolRates {
pub eur: Option<f32>, pub eur: Option<f32>,
} }
impl Default for ExchangeRateCache {
fn default() -> Self {
Self::new()
}
}
impl ExchangeRateCache { impl ExchangeRateCache {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {

View File

@ -1,5 +1,5 @@
use anyhow::{anyhow, bail, Result}; use anyhow::{anyhow, bail, Result};
use log::{debug, error, info}; use log::debug;
use reqwest::{ClientBuilder, Method, Url}; use reqwest::{ClientBuilder, Method, Url};
use serde::de::DeserializeOwned; use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -5,8 +5,8 @@ pub mod host;
pub mod invoice; pub mod invoice;
pub mod nip98; pub mod nip98;
pub mod provisioner; pub mod provisioner;
pub mod router;
pub mod settings; pub mod settings;
pub mod ssh_client;
pub mod status; pub mod status;
pub mod worker; pub mod worker;
pub mod router;
pub mod ssh_client;

View File

@ -1,8 +1,8 @@
use crate::exchange::{ExchangeRateCache, Ticker}; use crate::exchange::{ExchangeRateCache, Ticker};
use crate::host::get_host_client; use crate::host::get_host_client;
use crate::host::proxmox::{ use crate::host::proxmox::{
ConfigureVm, CreateVm, DownloadUrlRequest, ProxmoxClient, ResizeDiskRequest, StorageContent, CreateVm, DownloadUrlRequest, ProxmoxClient, ResizeDiskRequest, StorageContent, VmBios,
TaskState, VmBios, VmConfig, VmConfig,
}; };
use crate::provisioner::Provisioner; use crate::provisioner::Provisioner;
use crate::settings::{QemuConfig, SshConfig}; use crate::settings::{QemuConfig, SshConfig};
@ -14,11 +14,8 @@ use fedimint_tonic_lnd::tonic::async_trait;
use fedimint_tonic_lnd::Client; use fedimint_tonic_lnd::Client;
use ipnetwork::IpNetwork; use ipnetwork::IpNetwork;
use lnvps_db::hydrate::Hydrate; use lnvps_db::hydrate::Hydrate;
use lnvps_db::{ use lnvps_db::{IpRange, LNVpsDb, Vm, VmCostPlanIntervalType, VmIpAssignment, VmPayment};
IpRange, LNVpsDb, Vm, VmCostPlanIntervalType, VmHost, VmHostKind, VmIpAssignment, VmOsImage, use log::info;
VmPayment,
};
use log::{error, info, warn};
use nostr::util::hex; use nostr::util::hex;
use rand::random; use rand::random;
use rand::seq::IteratorRandom; use rand::seq::IteratorRandom;
@ -26,9 +23,7 @@ use reqwest::Url;
use std::collections::HashSet; use std::collections::HashSet;
use std::net::IpAddr; use std::net::IpAddr;
use std::ops::Add; use std::ops::Add;
use std::path::PathBuf;
use std::time::Duration; use std::time::Duration;
use tokio::time::sleep;
pub struct LNVpsProvisioner { pub struct LNVpsProvisioner {
db: Box<dyn LNVpsDb>, db: Box<dyn LNVpsDb>,
@ -146,9 +141,9 @@ impl Provisioner for LNVpsProvisioner {
disk_id: pick_disk.id, disk_id: pick_disk.id,
mac_address: format!( mac_address: format!(
"bc:24:11:{}:{}:{}", "bc:24:11:{}:{}:{}",
hex::encode(&[random::<u8>()]), hex::encode([random::<u8>()]),
hex::encode(&[random::<u8>()]), hex::encode([random::<u8>()]),
hex::encode(&[random::<u8>()]) hex::encode([random::<u8>()])
), ),
..Default::default() ..Default::default()
}; };

View File

@ -1,7 +1,6 @@
use std::net::IpAddr;
use lnvps_db::VmIpAssignment;
use rocket::async_trait;
use crate::router::Router; use crate::router::Router;
use rocket::async_trait;
use std::net::IpAddr;
pub struct MikrotikRouter { pub struct MikrotikRouter {
url: String, url: String,
@ -19,7 +18,12 @@ impl MikrotikRouter {
#[async_trait] #[async_trait]
impl Router for MikrotikRouter { impl Router for MikrotikRouter {
async fn add_arp_entry(&self, ip: IpAddr, mac: &[u8; 6], comment: Option<&str>) -> anyhow::Result<()> { async fn add_arp_entry(
&self,
ip: IpAddr,
mac: &[u8; 6],
comment: Option<&str>,
) -> anyhow::Result<()> {
todo!() todo!()
} }
} }

View File

@ -32,6 +32,12 @@ pub struct VmStateCache {
state: Arc<RwLock<HashMap<u64, VmState>>>, state: Arc<RwLock<HashMap<u64, VmState>>>,
} }
impl Default for VmStateCache {
fn default() -> Self {
Self::new()
}
}
impl VmStateCache { impl VmStateCache {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {

View File

@ -1,11 +1,11 @@
use crate::host::get_host_client; use crate::host::get_host_client;
use crate::host::proxmox::{ProxmoxClient, VmInfo, VmStatus}; use crate::host::proxmox::{VmInfo, VmStatus};
use crate::provisioner::Provisioner; use crate::provisioner::Provisioner;
use crate::status::{VmRunningState, VmState, VmStateCache}; use crate::status::{VmRunningState, VmState, VmStateCache};
use anyhow::Result; use anyhow::Result;
use chrono::{Days, Utc}; use chrono::{Days, Utc};
use lnvps_db::LNVpsDb; use lnvps_db::LNVpsDb;
use log::{debug, error, info, warn}; use log::{debug, error, info};
use std::ops::Add; use std::ops::Add;
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender}; use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender};