Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit b531075

Browse files
Fedimint cleanup
1 parent 84f934b commit b531075

4 files changed

Lines changed: 11 additions & 54 deletions

File tree

mutiny-core/src/federation.rs

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::{
55
nodemanager::MutinyInvoice,
66
onchain::coin_type_from_network,
77
sql::{glue::GlueDB, ApplicationStore},
8-
storage::MutinyStorage,
98
utils::{self, sleep},
109
ActivityItem, HTLCStatus, DEFAULT_PAYMENT_TIMEOUT,
1110
};
@@ -46,11 +45,7 @@ use futures_util::{pin_mut, StreamExt};
4645
use lightning::{log_debug, log_error, log_info, log_trace, log_warn, util::logger::Logger};
4746
use lightning_invoice::Bolt11Invoice;
4847
use serde::{de::DeserializeOwned, Deserialize, Serialize};
49-
use std::{
50-
collections::HashMap,
51-
fmt::Debug,
52-
sync::{atomic::AtomicBool, Arc, RwLock},
53-
};
48+
use std::{collections::HashMap, fmt::Debug, sync::Arc};
5449

5550
// The amount of time in milliseconds to wait for
5651
// checking the status of a fedimint payment. This
@@ -133,44 +128,25 @@ pub struct FedimintBalance {
133128
pub amount: u64,
134129
}
135130

136-
// TODO remove
137-
#[allow(dead_code)]
138-
pub(crate) struct FederationClient<S: MutinyStorage> {
131+
pub(crate) struct FederationClient {
139132
pub(crate) uuid: String,
140-
pub(crate) federation_index: FederationIndex,
141-
pub(crate) federation_code: InviteCode,
142133
pub(crate) fedimint_client: ClientArc,
143-
stopped_components: Arc<RwLock<Vec<bool>>>,
144-
storage: S,
145134
g: GlueDB,
146-
network: Network,
147135
pub(crate) logger: Arc<MutinyLogger>,
148-
stop: Arc<AtomicBool>,
149136
}
150137

151-
// TODO remove
152-
#[allow(dead_code)]
153-
impl<S: MutinyStorage> FederationClient<S> {
138+
impl FederationClient {
154139
#[allow(clippy::too_many_arguments)]
155140
pub(crate) async fn new(
156141
uuid: String,
157-
federation_index: &FederationIndex,
158142
federation_code: InviteCode,
159143
xprivkey: ExtendedPrivKey,
160-
storage: S,
161144
g: GlueDB,
162145
network: Network,
163146
logger: Arc<MutinyLogger>,
164-
stop: Arc<AtomicBool>,
165147
) -> Result<Self, MutinyError> {
166148
log_info!(logger, "initializing a new federation client: {uuid}");
167149

168-
// a list of components that need to be stopped and whether or not they are stopped
169-
// TODO remove this if we end up not needing to stop things
170-
let stopped_components = Arc::new(RwLock::new(vec![]));
171-
172-
log_info!(logger, "Joining federation {}", federation_code);
173-
174150
let federation_info = FederationInfo::from_invite_code(federation_code.clone()).await?;
175151

176152
let mut client_builder = fedimint_client::Client::builder();
@@ -201,15 +177,9 @@ impl<S: MutinyStorage> FederationClient<S> {
201177
log_debug!(logger, "Built fedimint client");
202178
Ok(FederationClient {
203179
uuid,
204-
federation_index: federation_index.clone(),
205-
federation_code,
206180
fedimint_client,
207-
stopped_components,
208-
storage,
209181
g,
210-
network,
211182
logger,
212-
stop,
213183
})
214184
}
215185

mutiny-core/src/lib.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ pub struct MutinyWallet<S: MutinyStorage> {
287287
pub node_manager: Arc<NodeManager<S>>,
288288
pub nostr: Arc<NostrManager<S>>,
289289
pub federation_storage: Arc<Mutex<FederationStorage>>,
290-
pub(crate) federations: Arc<Mutex<HashMap<FederationId, Arc<FederationClient<S>>>>>,
290+
pub(crate) federations: Arc<Mutex<HashMap<FederationId, Arc<FederationClient>>>>,
291291
pub stop: Arc<AtomicBool>,
292292
pub logger: Arc<MutinyLogger>,
293293
}
@@ -343,7 +343,7 @@ impl<S: MutinyStorage> MutinyWallet<S> {
343343

344344
// create federation library
345345
let (federation_storage, federations) =
346-
create_federations(&storage, &config, glue_db.clone(), &logger, stop.clone()).await?;
346+
create_federations(&storage, &config, glue_db.clone(), &logger).await?;
347347
let federation_storage = Arc::new(Mutex::new(federation_storage));
348348
let federations = federations;
349349

@@ -1031,7 +1031,6 @@ impl<S: MutinyStorage> MutinyWallet<S> {
10311031
self.federation_storage.clone(),
10321032
self.federations.clone(),
10331033
federation_code,
1034-
self.stop.clone(),
10351034
)
10361035
.await
10371036
}
@@ -1121,11 +1120,10 @@ async fn create_federations<S: MutinyStorage>(
11211120
c: &MutinyWalletConfig,
11221121
g: GlueDB,
11231122
logger: &Arc<MutinyLogger>,
1124-
stop: Arc<AtomicBool>,
11251123
) -> Result<
11261124
(
11271125
FederationStorage,
1128-
Arc<Mutex<HashMap<FederationId, Arc<FederationClient<S>>>>>,
1126+
Arc<Mutex<HashMap<FederationId, Arc<FederationClient>>>>,
11291127
),
11301128
MutinyError,
11311129
> {
@@ -1135,14 +1133,11 @@ async fn create_federations<S: MutinyStorage>(
11351133
for federation_item in federations {
11361134
let federation = FederationClient::new(
11371135
federation_item.0,
1138-
&federation_item.1,
11391136
federation_item.1.federation_code.clone(),
11401137
c.xprivkey,
1141-
storage.clone(),
11421138
g.clone(),
11431139
c.network,
11441140
logger.clone(),
1145-
stop.clone(),
11461141
)
11471142
.await?;
11481143

@@ -1163,9 +1158,8 @@ pub(crate) async fn create_new_federation<S: MutinyStorage>(
11631158
network: Network,
11641159
logger: Arc<MutinyLogger>,
11651160
federation_storage: Arc<Mutex<FederationStorage>>,
1166-
federations: Arc<Mutex<HashMap<FederationId, Arc<FederationClient<S>>>>>,
1161+
federations: Arc<Mutex<HashMap<FederationId, Arc<FederationClient>>>>,
11671162
federation_code: InviteCode,
1168-
stop: Arc<AtomicBool>,
11691163
) -> Result<FederationIdentity, MutinyError> {
11701164
// Begin with a mutex lock so that nothing else can
11711165
// save or alter the federation list while it is about to
@@ -1201,14 +1195,11 @@ pub(crate) async fn create_new_federation<S: MutinyStorage>(
12011195
// now create the federation process and init it
12021196
let new_federation = FederationClient::new(
12031197
next_federation_uuid.clone(),
1204-
&next_federation,
12051198
federation_code,
12061199
xprivkey,
1207-
storage.clone(),
12081200
g.clone(),
12091201
network,
12101202
logger.clone(),
1211-
stop,
12121203
)
12131204
.await?;
12141205

mutiny-core/src/sql/glue.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ impl GlueDB {
125125
}
126126

127127
impl ApplicationStore for GlueDB {
128-
#[cfg_attr(not(target_arch = "wasm32"), allow(dead_code, unused_variables))]
129128
async fn save_payment(&self, invoice: MutinyInvoice) -> Result<(), MutinyError> {
130129
#[cfg(not(target_arch = "wasm32"))]
131130
unimplemented!("can't run on servers until Send is supported in Glue");
@@ -201,7 +200,6 @@ impl ApplicationStore for GlueDB {
201200
}
202201
}
203202

204-
#[cfg_attr(not(target_arch = "wasm32"), allow(dead_code, unused_variables))]
205203
async fn get_payment(
206204
&self,
207205
payment_hash: &bitcoin::hashes::sha256::Hash,
@@ -255,7 +253,6 @@ impl ApplicationStore for GlueDB {
255253
}
256254
}
257255

258-
#[cfg_attr(not(target_arch = "wasm32"), allow(dead_code, unused_variables))]
259256
async fn update_payment_status(
260257
&self,
261258
payment_hash: &bitcoin::hashes::sha256::Hash,
@@ -284,7 +281,6 @@ impl ApplicationStore for GlueDB {
284281
}
285282
}
286283

287-
#[cfg_attr(not(target_arch = "wasm32"), allow(dead_code, unused_variables))]
288284
async fn update_payment_fee(
289285
&self,
290286
payment_hash: &bitcoin::hashes::sha256::Hash,
@@ -316,7 +312,6 @@ impl ApplicationStore for GlueDB {
316312
}
317313
}
318314

319-
#[cfg_attr(not(target_arch = "wasm32"), allow(dead_code, unused_variables))]
320315
async fn update_payment_preimage(
321316
&self,
322317
payment_hash: &bitcoin::hashes::sha256::Hash,
@@ -348,7 +343,6 @@ impl ApplicationStore for GlueDB {
348343
}
349344
}
350345

351-
#[cfg_attr(not(target_arch = "wasm32"), allow(dead_code))]
352346
async fn list_payments(&self) -> Result<Vec<MutinyInvoice>, MutinyError> {
353347
#[cfg(not(target_arch = "wasm32"))]
354348
unimplemented!("can't run on servers until Send is supported in Glue");
@@ -382,7 +376,6 @@ impl ApplicationStore for GlueDB {
382376
}
383377
}
384378

385-
#[cfg_attr(not(target_arch = "wasm32"), allow(dead_code))]
386379
fn parse_row_to_invoice(
387380
row: Vec<Value>,
388381
logger: Arc<MutinyLogger>,
@@ -598,7 +591,6 @@ impl IRawDatabase for FedimintDB {
598591
}
599592
}
600593

601-
#[cfg_attr(not(target_arch = "wasm32"), allow(dead_code))]
602594
pub struct GluePseudoTransaction<'a> {
603595
#[cfg(not(target_arch = "wasm32"))]
604596
pub(crate) db: Arc<Mutex<Glue<MemoryStorage>>>,

mutiny-core/src/sql/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#![cfg_attr(
2+
not(target_arch = "wasm32"),
3+
allow(unused_variables, dead_code, unused_imports)
4+
)]
15
use crate::{error::MutinyError, nodemanager::MutinyInvoice, HTLCStatus};
26

37
pub mod glue;

0 commit comments

Comments
 (0)