Skip to content

Commit b13f155

Browse files
committed
Drop bogus channel state handling
.. we will re-add a proper state machine in a later commit, but for now we can just drop all of this half-baked logic that doesn't actually do anything.
1 parent cae7fa5 commit b13f155

File tree

2 files changed

+2
-62
lines changed

2 files changed

+2
-62
lines changed

lightning-liquidity/src/lsps1/peer_state.rs

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ use super::msgs::{LSPS1OrderId, LSPS1OrderParams, LSPS1PaymentInfo, LSPS1Request
1414
use crate::lsps0::ser::{LSPSDateTime, LSPSRequestId};
1515
use crate::prelude::HashMap;
1616

17-
use lightning::ln::msgs::{ErrorAction, LightningError};
18-
use lightning::util::logger::Level;
19-
2017
#[derive(Default)]
2118
pub(super) struct PeerState {
2219
pub(super) outbound_channels_by_order_id: HashMap<LSPS1OrderId, OutboundCRChannel>,
@@ -31,54 +28,20 @@ impl PeerState {
3128
}
3229
}
3330

34-
struct ChannelStateError(String);
35-
36-
impl From<ChannelStateError> for LightningError {
37-
fn from(value: ChannelStateError) -> Self {
38-
LightningError { err: value.0, action: ErrorAction::IgnoreAndLog(Level::Info) }
39-
}
40-
}
41-
42-
#[derive(PartialEq, Debug)]
43-
pub(super) enum OutboundRequestState {
44-
OrderCreated { order_id: LSPS1OrderId },
45-
WaitingPayment { order_id: LSPS1OrderId },
46-
}
47-
48-
impl OutboundRequestState {
49-
fn awaiting_payment(&self) -> Result<Self, ChannelStateError> {
50-
match self {
51-
OutboundRequestState::OrderCreated { order_id } => {
52-
Ok(OutboundRequestState::WaitingPayment { order_id: order_id.clone() })
53-
},
54-
state => Err(ChannelStateError(format!("TODO. JIT Channel was in state: {:?}", state))),
55-
}
56-
}
57-
}
58-
5931
pub(super) struct OutboundLSPS1Config {
6032
pub(super) order: LSPS1OrderParams,
6133
pub(super) created_at: LSPSDateTime,
6234
pub(super) payment: LSPS1PaymentInfo,
6335
}
6436

6537
pub(super) struct OutboundCRChannel {
66-
pub(super) state: OutboundRequestState,
6738
pub(super) config: OutboundLSPS1Config,
6839
}
6940

7041
impl OutboundCRChannel {
7142
pub(super) fn new(
72-
order: LSPS1OrderParams, created_at: LSPSDateTime, order_id: LSPS1OrderId,
73-
payment: LSPS1PaymentInfo,
43+
order: LSPS1OrderParams, created_at: LSPSDateTime, payment: LSPS1PaymentInfo,
7444
) -> Self {
75-
Self {
76-
state: OutboundRequestState::OrderCreated { order_id },
77-
config: OutboundLSPS1Config { order, created_at, payment },
78-
}
79-
}
80-
pub(super) fn awaiting_payment(&mut self) -> Result<(), LightningError> {
81-
self.state = self.state.awaiting_payment()?;
82-
Ok(())
45+
Self { config: OutboundLSPS1Config { order, created_at, payment } }
8346
}
8447
}

lightning-liquidity/src/lsps1/service.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ where
198198
let channel = OutboundCRChannel::new(
199199
params.order.clone(),
200200
created_at,
201-
order_id.clone(),
202201
payment.clone(),
203202
);
204203

@@ -237,28 +236,6 @@ where
237236
match outer_state_lock.get(counterparty_node_id) {
238237
Some(inner_state_lock) => {
239238
let mut peer_state_lock = inner_state_lock.lock().unwrap();
240-
241-
let outbound_channel = peer_state_lock
242-
.outbound_channels_by_order_id
243-
.get_mut(&params.order_id)
244-
.ok_or(LightningError {
245-
err: format!(
246-
"Received get order request for unknown order id {:?}",
247-
params.order_id
248-
),
249-
action: ErrorAction::IgnoreAndLog(Level::Info),
250-
})?;
251-
252-
if let Err(e) = outbound_channel.awaiting_payment() {
253-
peer_state_lock.outbound_channels_by_order_id.remove(&params.order_id);
254-
event_queue_notifier.enqueue(LSPS1ServiceEvent::Refund {
255-
request_id,
256-
counterparty_node_id: *counterparty_node_id,
257-
order_id: params.order_id,
258-
});
259-
return Err(e);
260-
}
261-
262239
peer_state_lock
263240
.pending_requests
264241
.insert(request_id.clone(), LSPS1Request::GetOrder(params.clone()));

0 commit comments

Comments
 (0)