Skip to content

Commit 810f026

Browse files
committed
Drop chain_source from LSPS1ServiceHandler
We previously considered tracking payment confirmations as part of the handler. However, we can considerably simplify our logic if we stick with the current approach of having the LSPs track the payment status and update us when prompted through events.
1 parent ce7ff1d commit 810f026

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

lightning-liquidity/src/lsps1/service.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use crate::prelude::{new_hash_map, HashMap};
3030
use crate::sync::{Arc, Mutex, RwLock};
3131
use crate::utils;
3232

33-
use lightning::chain::Filter;
3433
use lightning::ln::channelmanager::AChannelManager;
3534
use lightning::ln::msgs::{ErrorAction, LightningError};
3635
use lightning::sign::EntropySource;
@@ -114,40 +113,35 @@ impl PeerState {
114113
}
115114

116115
/// The main object allowing to send and receive bLIP-51 / LSPS1 messages.
117-
pub struct LSPS1ServiceHandler<ES: Deref, CM: Deref + Clone, C: Deref, K: Deref + Clone>
116+
pub struct LSPS1ServiceHandler<ES: Deref, CM: Deref + Clone, K: Deref + Clone>
118117
where
119118
ES::Target: EntropySource,
120119
CM::Target: AChannelManager,
121-
C::Target: Filter,
122120
K::Target: KVStore,
123121
{
124122
entropy_source: ES,
125123
_channel_manager: CM,
126-
_chain_source: Option<C>,
127124
pending_messages: Arc<MessageQueue>,
128125
pending_events: Arc<EventQueue<K>>,
129126
per_peer_state: RwLock<HashMap<PublicKey, Mutex<PeerState>>>,
130127
config: LSPS1ServiceConfig,
131128
}
132129

133-
impl<ES: Deref, CM: Deref + Clone, C: Deref, K: Deref + Clone> LSPS1ServiceHandler<ES, CM, C, K>
130+
impl<ES: Deref, CM: Deref + Clone, K: Deref + Clone> LSPS1ServiceHandler<ES, CM, K>
134131
where
135132
ES::Target: EntropySource,
136133
CM::Target: AChannelManager,
137-
C::Target: Filter,
138134
ES::Target: EntropySource,
139135
K::Target: KVStore,
140136
{
141137
/// Constructs a `LSPS1ServiceHandler`.
142138
pub(crate) fn new(
143139
entropy_source: ES, pending_messages: Arc<MessageQueue>,
144-
pending_events: Arc<EventQueue<K>>, channel_manager: CM, chain_source: Option<C>,
145-
config: LSPS1ServiceConfig,
140+
pending_events: Arc<EventQueue<K>>, channel_manager: CM, config: LSPS1ServiceConfig,
146141
) -> Self {
147142
Self {
148143
entropy_source,
149144
_channel_manager: channel_manager,
150-
_chain_source: chain_source,
151145
pending_messages,
152146
pending_events,
153147
per_peer_state: RwLock::new(new_hash_map()),
@@ -403,12 +397,11 @@ where
403397
}
404398
}
405399

406-
impl<ES: Deref, CM: Deref + Clone, C: Deref, K: Deref + Clone> LSPSProtocolMessageHandler
407-
for LSPS1ServiceHandler<ES, CM, C, K>
400+
impl<ES: Deref, CM: Deref + Clone, K: Deref + Clone> LSPSProtocolMessageHandler
401+
for LSPS1ServiceHandler<ES, CM, K>
408402
where
409403
ES::Target: EntropySource,
410404
CM::Target: AChannelManager,
411-
C::Target: Filter,
412405
K::Target: KVStore,
413406
{
414407
type ProtocolMessage = LSPS1Message;

lightning-liquidity/src/manager.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ pub struct LiquidityManager<
322322
lsps0_client_handler: LSPS0ClientHandler<ES, K>,
323323
lsps0_service_handler: Option<LSPS0ServiceHandler>,
324324
#[cfg(lsps1_service)]
325-
lsps1_service_handler: Option<LSPS1ServiceHandler<ES, CM, C, K>>,
325+
lsps1_service_handler: Option<LSPS1ServiceHandler<ES, CM, K>>,
326326
lsps1_client_handler: Option<LSPS1ClientHandler<ES, K>>,
327327
lsps2_service_handler: Option<LSPS2ServiceHandler<CM, K, T>>,
328328
lsps2_client_handler: Option<LSPS2ClientHandler<ES, K>>,
@@ -509,7 +509,7 @@ where
509509
#[cfg(lsps1_service)]
510510
let lsps1_service_handler = service_config.as_ref().and_then(|config| {
511511
if let Some(number) =
512-
<LSPS1ServiceHandler<ES, CM, C, K> as LSPSProtocolMessageHandler>::PROTOCOL_NUMBER
512+
<LSPS1ServiceHandler<ES, CM, K> as LSPSProtocolMessageHandler>::PROTOCOL_NUMBER
513513
{
514514
supported_protocols.push(number);
515515
}
@@ -519,7 +519,6 @@ where
519519
Arc::clone(&pending_messages),
520520
Arc::clone(&pending_events),
521521
channel_manager.clone(),
522-
chain_source.clone(),
523522
config.clone(),
524523
)
525524
})
@@ -579,7 +578,7 @@ where
579578

580579
/// Returns a reference to the LSPS1 server-side handler.
581580
#[cfg(lsps1_service)]
582-
pub fn lsps1_service_handler(&self) -> Option<&LSPS1ServiceHandler<ES, CM, C, K>> {
581+
pub fn lsps1_service_handler(&self) -> Option<&LSPS1ServiceHandler<ES, CM, K>> {
583582
self.lsps1_service_handler.as_ref()
584583
}
585584

@@ -1215,7 +1214,7 @@ where
12151214
#[cfg(lsps1_service)]
12161215
pub fn lsps1_service_handler(
12171216
&self,
1218-
) -> Option<&LSPS1ServiceHandler<ES, CM, C, KVStoreSyncWrapper<KS>>> {
1217+
) -> Option<&LSPS1ServiceHandler<ES, CM, KVStoreSyncWrapper<KS>>> {
12191218
self.inner.lsps1_service_handler()
12201219
}
12211220

0 commit comments

Comments
 (0)