Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fce3d60
chore: enable clippy nursery and pedantic rules
tvolk131 Aug 20, 2025
7207e38
chore: enforce clippy cast_lossless rule
tvolk131 Aug 25, 2025
e2322fd
chore: enforce clippy doc_markdown rule
tvolk131 Aug 25, 2025
25abd23
chore: enforce clippy explicit_iter_loop rule
tvolk131 Aug 26, 2025
58cc3bf
chore: enforce clippy future_not_send rule
tvolk131 Aug 26, 2025
dd3490a
chore: enforce clippy if_not_else rule
tvolk131 Aug 26, 2025
53212e7
chore: enforce clippy ignored_unit_patterns rule
tvolk131 Aug 26, 2025
5834451
chore: enforce clippy implicit_clone rule
tvolk131 Aug 26, 2025
278f996
chore: enforce clippy items_after_statements rule
tvolk131 Aug 26, 2025
a143a1b
chore: enforce clippy manual_string_new rule
tvolk131 Aug 26, 2025
2870090
chore: enforce clippy map_unwrap_or rule
tvolk131 Aug 26, 2025
6cce7ca
chore: enforce clippy match_bool rule
tvolk131 Aug 26, 2025
7ad0bc9
chore: enforce clippy match_wildcard_for_single_variants rule
tvolk131 Aug 26, 2025
b3543fb
chore: enforce clippy needless_collect rule
tvolk131 Aug 26, 2025
94abcb2
chore: enforce clippy needless_pass_by_ref_mut rule
tvolk131 Aug 26, 2025
8608e36
chore: simplify SQLConnection::get_profile
tvolk131 Aug 26, 2025
20a9f4d
chore: enforce clippy redundant_clone rule
tvolk131 Aug 26, 2025
a746990
chore: enforce clippy redundant_pub_crate rule
tvolk131 Aug 26, 2025
46aa0d0
chore: enforce clippy semicolon_if_nothing_returned rule
tvolk131 Aug 26, 2025
8f9e738
chore: enforce clippy uninlined_format_args rule
tvolk131 Aug 26, 2025
eba55fa
chore: enforce clippy unnecessary_wraps rule
tvolk131 Aug 26, 2025
2640b6c
chore: enforce clippy unreadable_literal rule
tvolk131 Aug 26, 2025
4cfa1e1
chore: enforce clippy unused_async rule
tvolk131 Aug 26, 2025
0a6aa51
chore: enforce clippy use_self rule
tvolk131 Aug 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions harbor-client/src/cashu_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ impl TorMintConnector {
}

#[inline]
async fn http_post<P: Serialize + ?Sized, R: DeserializeOwned + Send + 'static>(
async fn http_post<P: Serialize, R: DeserializeOwned + Send + 'static>(
&self,
url: Url,
payload: &P,
payload: P,
) -> Result<R, Error> {
let res: R = make_tor_request(url.as_str(), Some(payload), self.cancel_handle.clone())
.await
Expand Down
5 changes: 1 addition & 4 deletions harbor-client/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,7 @@ impl DBConnection for SQLConnection {

fn get_profile(&self) -> anyhow::Result<Option<Profile>> {
let conn = &mut self.db.get()?;
match Profile::get_first(conn)? {
Some(p) => Ok(Some(p)),
None => Ok(None),
}
Profile::get_first(conn)
}

fn insert_new_profile(&self, new_profile: NewProfile) -> anyhow::Result<Profile> {
Expand Down
10 changes: 5 additions & 5 deletions harbor-client/src/db_models/cashu_mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ pub struct CashuMint {
}

impl CashuMint {
pub fn get(conn: &mut SqliteConnection, url: String) -> anyhow::Result<Option<CashuMint>> {
pub fn get(conn: &mut SqliteConnection, url: String) -> anyhow::Result<Option<Self>> {
Ok(cashu_mint::table
.filter(cashu_mint::mint_url.eq(url))
.first::<CashuMint>(conn)
.first::<Self>(conn)
.optional()?)
}

Expand All @@ -32,7 +32,7 @@ impl CashuMint {
let exists = cashu_mint::table
.filter(cashu_mint::mint_url.eq(&url))
.filter(cashu_mint::active.eq(1))
.first::<CashuMint>(conn)
.first::<Self>(conn)
.optional()?
.is_some();

Expand Down Expand Up @@ -79,15 +79,15 @@ impl CashuMint {
// First check if the federation exists and is active
let exists = cashu_mint::table
.filter(cashu_mint::mint_url.eq(&mint_url))
.first::<CashuMint>(conn)
.first::<Self>(conn)
.optional()?
.is_some();

if exists {
Self::set_active(conn, &mint_url)?;
}

let mint = CashuMint {
let mint = Self {
mint_url,
active: 1,
};
Expand Down
10 changes: 5 additions & 5 deletions harbor-client/src/db_models/fedimint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ impl Fedimint {
pub fn get_value(conn: &mut SqliteConnection, id: String) -> anyhow::Result<Option<Vec<u8>>> {
Ok(fedimint::table
.filter(fedimint::id.eq(id))
.first::<Fedimint>(conn)
.first::<Self>(conn)
.optional()?
.map(|v| v.value))
}

pub fn get(conn: &mut SqliteConnection, id: String) -> anyhow::Result<Option<Fedimint>> {
pub fn get(conn: &mut SqliteConnection, id: String) -> anyhow::Result<Option<Self>> {
Ok(fedimint::table
.filter(fedimint::id.eq(id))
.first::<Fedimint>(conn)
.first::<Self>(conn)
.optional()?)
}

Expand All @@ -34,7 +34,7 @@ impl Fedimint {
let exists = fedimint::table
.filter(fedimint::id.eq(&id))
.filter(fedimint::active.eq(1))
.first::<Fedimint>(conn)
.first::<Self>(conn)
.optional()?
.is_some();

Expand Down Expand Up @@ -101,7 +101,7 @@ pub struct NewFedimint {

impl From<&NewFedimint> for Fedimint {
fn from(new_fedimint: &NewFedimint) -> Self {
Fedimint {
Self {
id: new_fedimint.id.clone(),
invite_code: new_fedimint.invite_code.clone(),
value: new_fedimint.value.clone(),
Expand Down
10 changes: 5 additions & 5 deletions harbor-client/src/db_models/mint_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct MintMetadata {

impl MintMetadata {
pub fn from(id: FederationId, meta: FederationMeta) -> Self {
MintMetadata {
Self {
id: id.to_string(),
federation_expiry_timestamp: meta
.federation_expiry_timestamp()
Expand All @@ -38,10 +38,10 @@ impl MintMetadata {
}
}

pub fn get(conn: &mut SqliteConnection, id: String) -> anyhow::Result<Option<MintMetadata>> {
pub fn get(conn: &mut SqliteConnection, id: String) -> anyhow::Result<Option<Self>> {
Ok(mint_metadata::table
.filter(mint_metadata::id.eq(id))
.first::<MintMetadata>(conn)
.first::<Self>(conn)
.optional()?)
}

Expand Down Expand Up @@ -73,8 +73,8 @@ impl MintMetadata {
}

impl From<MintMetadata> for FederationMeta {
fn from(value: MintMetadata) -> FederationMeta {
FederationMeta {
fn from(value: MintMetadata) -> Self {
Self {
federation_name: value.name,
federation_expiry_timestamp: value.federation_expiry_timestamp.map(|f| f.to_string()),
welcome_message: value.welcome_message,
Expand Down
8 changes: 4 additions & 4 deletions harbor-client/src/db_models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ pub enum PaymentStatus {
impl PaymentStatus {
pub fn from_i32(status: i32) -> Self {
match status {
0 => PaymentStatus::Pending,
1 => PaymentStatus::WaitingConfirmation,
2 => PaymentStatus::Success,
3 => PaymentStatus::Failed,
0 => Self::Pending,
1 => Self::WaitingConfirmation,
2 => Self::Success,
3 => Self::Failed,
_ => panic!("invalid status"),
}
}
Expand Down
10 changes: 5 additions & 5 deletions harbor-client/src/db_models/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ pub struct Profile {
}

impl Profile {
pub fn get_first(conn: &mut SqliteConnection) -> anyhow::Result<Option<Profile>> {
Ok(profile::table.first::<Profile>(conn).optional()?)
pub fn get_first(conn: &mut SqliteConnection) -> anyhow::Result<Option<Self>> {
Ok(profile::table.first::<Self>(conn).optional()?)
}

pub fn set_onchain_receive_enabled(
Expand All @@ -29,7 +29,7 @@ impl Profile {
enabled
);
diesel::update(profile::table)
.set(profile::onchain_receive_enabled.eq(enabled as i32))
.set(profile::onchain_receive_enabled.eq(i32::from(enabled)))
.execute(conn)?;
log::debug!("Successfully updated on-chain receive enabled setting in database");
Ok(())
Expand All @@ -42,7 +42,7 @@ impl Profile {
pub fn set_tor_enabled(conn: &mut SqliteConnection, enabled: bool) -> anyhow::Result<()> {
log::debug!("Updating Tor enabled setting in database to: {}", enabled);
diesel::update(profile::table)
.set(profile::tor_enabled.eq(enabled as i32))
.set(profile::tor_enabled.eq(i32::from(enabled)))
.execute(conn)?;
log::debug!("Successfully updated Tor enabled setting in database");
Ok(())
Expand All @@ -66,7 +66,7 @@ pub struct NewProfile {

impl From<&NewProfile> for Profile {
fn from(new_profile: &NewProfile) -> Self {
Profile {
Self {
id: new_profile.id.clone(),
seed_words: new_profile.seed_words.clone(),
onchain_receive_enabled: 0,
Expand Down
18 changes: 9 additions & 9 deletions harbor-client/src/fedimint_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ pub enum FederationInviteOrId {
impl FederationInviteOrId {
pub fn federation_id(&self) -> FederationId {
match self {
FederationInviteOrId::Invite(i) => i.federation_id(),
FederationInviteOrId::Id(i) => *i,
Self::Invite(i) => i.federation_id(),
Self::Id(i) => *i,
}
}

pub fn invite_code(&self) -> Option<InviteCode> {
match self {
FederationInviteOrId::Invite(i) => Some(i.clone()),
FederationInviteOrId::Id(_) => None,
Self::Invite(i) => Some(i.clone()),
Self::Id(_) => None,
}
}
}
Expand Down Expand Up @@ -170,7 +170,7 @@ impl FedimintClient {
)
.await;
match client.wait_for_all_recoveries().await {
Ok(_) => {
Ok(()) => {
info!("Federation successfully recovered");
HarborCore::send_msg(
&mut sender,
Expand Down Expand Up @@ -240,7 +240,7 @@ impl FedimintClient {
let start = Instant::now();
match client.backup_to_federation(Metadata::empty()).await {
Err(e) => error!("Could not create backup to federation: {e}"),
Ok(_) => info!("Successfully created backup to federation"),
Ok(()) => info!("Successfully created backup to federation"),
}

info!("Creating backup took: {}ms", start.elapsed().as_millis());
Expand All @@ -255,7 +255,7 @@ impl FedimintClient {
.expect("must have ln module");

match lightning_module.update_gateway_cache().await {
Ok(_) => {
Ok(()) => {
trace!("Updated lightning gateway cache");
}
Err(e) => {
Expand All @@ -276,7 +276,7 @@ impl FedimintClient {

debug!("Built fedimint client");

Ok(FedimintClient {
Ok(Self {
fedimint_client,
stop,
})
Expand All @@ -294,7 +294,7 @@ pub(crate) async fn select_gateway(client: &ClientHandleArc) -> Option<Lightning

let gateways = ln.list_gateways().await;
let mut selected_gateway: Option<LightningGateway> = None;
for gateway in gateways.iter() {
for gateway in &gateways {
// first try to find a vetted gateway
if gateway.vetted {
// if we can select the gateway, return it
Expand Down
Loading
Loading