Skip to content

Commit 6b98f51

Browse files
committed
no secondary types
1 parent 370d677 commit 6b98f51

File tree

3 files changed

+14
-39
lines changed

3 files changed

+14
-39
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use lightning::onion_message::messenger::AOnionMessenger;
3636
use lightning::routing::gossip::{NetworkGraph, P2PGossipSync};
3737
use lightning::routing::scoring::{ScoreUpdate, WriteableScore};
3838
use lightning::routing::utxo::UtxoLookup;
39-
use lightning::sign::{ChangeDestinationSource, OutputSpender};
39+
use lightning::sign::{ChangeDestinationSourceSync, ChangeDestinationSource, OutputSpender};
4040
use lightning::util::logger::Logger;
4141
use lightning::util::persist::{KVStore, Persister};
4242
use lightning::util::sweep::OutputSweeper;
@@ -946,7 +946,7 @@ impl BackgroundProcessor {
946946
PM: 'static + Deref + Send + Sync,
947947
S: 'static + Deref<Target = SC> + Send + Sync,
948948
SC: for<'b> WriteableScore<'b>,
949-
D: 'static + Deref + Send + Sync,
949+
D: 'static + Deref + Send + Sync + Sized,
950950
O: 'static + Deref + Send + Sync,
951951
K: 'static + Deref + Send + Sync,
952952
OS: 'static + Deref<Target = OutputSweeper<T, D, F, CF, K, L, O>> + Send + Sync,
@@ -967,7 +967,7 @@ impl BackgroundProcessor {
967967
OM::Target: AOnionMessenger + Send + Sync,
968968
PM::Target: APeerManager + Send + Sync,
969969
O::Target: 'static + OutputSpender + Send + Sync,
970-
D::Target: 'static + ChangeDestinationSource + Send + Sync,
970+
D::Target: 'static + ChangeDestinationSourceSync + Send + Sync + Sized,
971971
K::Target: 'static + KVStore + Send + Sync,
972972
{
973973
let stop_thread = Arc::new(AtomicBool::new(false));

lightning/src/sign/mod.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,19 +1005,9 @@ pub trait ChangeDestinationSourceSync {
10051005
fn get_change_destination_script(&self) -> Result<ScriptBuf, ()>;
10061006
}
10071007

1008-
/// A wrapper around [`ChangeDestinationSource`] to allow for async calls.
1009-
pub struct ChangeDestinationSourceSyncWrapper<T>(T) where T: ChangeDestinationSourceSync;
1010-
1011-
impl<T: ChangeDestinationSourceSync> ChangeDestinationSourceSyncWrapper<T> {
1012-
/// Creates a new [`ChangeDestinationSourceSyncWrapper`].
1013-
pub fn new(source: T) -> Self {
1014-
Self(source)
1015-
}
1016-
}
1017-
1018-
impl<T: ChangeDestinationSourceSync> ChangeDestinationSource for ChangeDestinationSourceSyncWrapper<T> {
1008+
impl<T: ChangeDestinationSourceSync> ChangeDestinationSource for T {
10191009
fn get_change_destination_script<'a>(&self) -> AsyncGetChangeDestinationScriptResult<'a, ScriptBuf> {
1020-
let script = self.0.get_change_destination_script();
1010+
let script = self.get_change_destination_script();
10211011
Box::pin(async move { script })
10221012
}
10231013
}

lightning/src/util/sweep.rs

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::io;
1515
use crate::ln::msgs::DecodeError;
1616
use crate::ln::types::ChannelId;
1717
use crate::prelude::*;
18-
use crate::sign::{ChangeDestinationSource, ChangeDestinationSourceSync, ChangeDestinationSourceSyncWrapper, OutputSpender, SpendableOutputDescriptor};
18+
use crate::sign::{ChangeDestinationSource, ChangeDestinationSourceSync, OutputSpender, SpendableOutputDescriptor};
1919
use crate::sync::Mutex;
2020
use crate::util::logger::Logger;
2121
use crate::util::persist::{
@@ -357,46 +357,31 @@ where
357357
logger: L,
358358
}
359359

360-
pub struct OutputSweeperSync<B: Deref, D: Deref, E: Deref, F: Deref, K: Deref, L: Deref, O: Deref>
360+
impl<B: Deref, D: Deref + Sized, E: Deref, F: Deref, K: Deref, L: Deref, O: Deref>
361+
OutputSweeper<B, D, E, F, K, L, O>
361362
where
362363
B::Target: BroadcasterInterface,
363-
D::Target: ChangeDestinationSource,
364+
D::Target: ChangeDestinationSourceSync + Sized,
364365
E::Target: FeeEstimator,
365366
F::Target: Filter + Sync + Send,
366367
K::Target: KVStore,
367368
L::Target: Logger,
368369
O::Target: OutputSpender,
369370
{
370-
sweeper: OutputSweeper<B, D, E, F, K, L, O>,
371-
}
372-
373-
impl<B: Deref, D: Deref, E: Deref, F: Deref, K: Deref, L: Deref, O: Deref>
374-
OutputSweeperSync<B, D, E, F, K, L, O>
375-
where
376-
B::Target: BroadcasterInterface,
377-
D::Target: ChangeDestinationSource,
378-
E::Target: FeeEstimator,
379-
F::Target: Filter + Sync + Send,
380-
K::Target: KVStore,
381-
L::Target: Logger,
382-
O::Target: OutputSpender,
383-
{
384-
fn new<DA: ChangeDestinationSourceSync>(
371+
fn new_sync(
385372
best_block: BestBlock, broadcaster: B, fee_estimator: E, chain_data_source: Option<F>,
386-
output_spender: O, change_destination_source: DA, kv_store: K, logger: L,
373+
output_spender: O, change_destination_source: D, kv_store: K, logger: L,
387374
) -> Self {
388-
let change_destination_source = Arc::new(ChangeDestinationSourceSyncWrapper::new(change_destination_source));
389375

390-
let sweeper = OutputSweeper::new(
376+
OutputSweeper::new(
391377
best_block, broadcaster, fee_estimator, chain_data_source, output_spender,
392378
change_destination_source, kv_store, logger,
393-
);
394-
Self { sweeper }
379+
)
395380
}
396381

397382
/// Regenerates and broadcasts the spending transaction for any outputs that are pending
398383
pub fn regenerate_and_broadcast_spend_if_necessary(&self) -> Result<(), ()> {
399-
let mut fut = Box::pin(self.sweeper.regenerate_and_broadcast_spend_if_necessary_async());
384+
let mut fut = Box::pin(self.regenerate_and_broadcast_spend_if_necessary_async());
400385
let mut waker = dummy_waker();
401386
let mut ctx = task::Context::from_waker(&mut waker);
402387
match fut.as_mut().poll(&mut ctx) {

0 commit comments

Comments
 (0)