Make LSPSDateTime Copy rather than explicitely _clone_ing
What changed, and why it matters
This commit is a small internal code cleanup. It makes a date/time wrapper type copyable by value instead of requiring an explicit clone, and removes a few now-unnecessary `.clone()` calls. There is no security-relevant change and no user-facing behavior difference.
No action required. This is a non-security refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change derives Copy for LSPSDateTime (a newtype around chrono::DateTime<Utc>) and replaces explicit .clone() calls on values of that type with direct copies. chrono::DateTime<Utc> already implements Copy, so this is purely a Rust ergonomics/performance micro-optimization. No logic, serialization format, API, or trust boundary changes are present.
Changed components
lightning-liquidity/src/lsps0/ser.rslightning-liquidity/src/lsps1/service.rslightning-liquidity/src/lsps2/msgs.rslightning-liquidity/src/lsps5/service.rsInspect captured patch +7 / −7
diff --git a/lightning-liquidity/src/lsps0/ser.rs b/lightning-liquidity/src/lsps0/ser.rs
index 0c44b6f..213e276 100644
--- a/lightning-liquidity/src/lsps0/ser.rs
+++ b/lightning-liquidity/src/lsps0/ser.rs
@@ -218,7 +218,7 @@ impl wire::Type for RawLSPSMessage {
pub struct LSPSRequestId(pub String);
/// An object representing datetimes as described in bLIP-50 / LSPS0.
-#[derive(Clone, Debug, PartialEq, Eq, Hash, Deserialize, Serialize)]
+#[derive(Clone, Debug, Copy, PartialEq, Eq, Hash, Deserialize, Serialize)]
#[serde(transparent)]
pub struct LSPSDateTime(pub chrono::DateTime<chrono::Utc>);
diff --git a/lightning-liquidity/src/lsps1/service.rs b/lightning-liquidity/src/lsps1/service.rs
index 4dadf2e..aa10e73 100644
--- a/lightning-liquidity/src/lsps1/service.rs
+++ b/lightning-liquidity/src/lsps1/service.rs
@@ -266,7 +266,7 @@ where
let order_id = self.generate_order_id();
let channel = OutboundCRChannel::new(
params.order.clone(),
- created_at.clone(),
+ created_at,
order_id.clone(),
payment.clone(),
);
diff --git a/lightning-liquidity/src/lsps2/msgs.rs b/lightning-liquidity/src/lsps2/msgs.rs
index 84875d4..8fb9536 100644
--- a/lightning-liquidity/src/lsps2/msgs.rs
+++ b/lightning-liquidity/src/lsps2/msgs.rs
@@ -72,7 +72,7 @@ impl LSPS2RawOpeningFeeParams {
LSPS2OpeningFeeParams {
min_fee_msat: self.min_fee_msat,
proportional: self.proportional,
- valid_until: self.valid_until.clone(),
+ valid_until: self.valid_until,
min_lifetime: self.min_lifetime,
max_client_to_self_delay: self.max_client_to_self_delay,
min_payment_size_msat: self.min_payment_size_msat,
@@ -235,7 +235,7 @@ mod tests {
let raw = LSPS2RawOpeningFeeParams {
min_fee_msat,
proportional,
- valid_until: valid_until.clone().into(),
+ valid_until: valid_until.into(),
min_lifetime,
max_client_to_self_delay,
min_payment_size_msat,
diff --git a/lightning-liquidity/src/lsps5/service.rs b/lightning-liquidity/src/lsps5/service.rs
index 4b2e596..e0fb3ab 100644
--- a/lightning-liquidity/src/lsps5/service.rs
+++ b/lightning-liquidity/src/lsps5/service.rs
@@ -185,7 +185,7 @@ where
Entry::Occupied(mut entry) => {
no_change = entry.get().url == params.webhook;
let (last_used, last_notification_sent) = if no_change {
- (entry.get().last_used.clone(), entry.get().last_notification_sent.clone())
+ (entry.get().last_used, entry.get().last_notification_sent.clone())
} else {
(now, new_hash_map())
};
@@ -438,8 +438,8 @@ where
}
for (app_name, webhook) in client_webhooks.iter_mut() {
- webhook.last_notification_sent.insert(notification.method.clone(), now.clone());
- webhook.last_used = now.clone();
+ webhook.last_notification_sent.insert(notification.method.clone(), now);
+ webhook.last_used = now;
self.send_notification(
client_id,
app_name.clone(),
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.