Skip to content

Commit c54964f

Browse files
committed
Use MonitorName when persisting ChannelMonitors
Instead repeating the MonitorName formatting when persisting monitors, DRY up the code to use MonitorName::from instead.
1 parent 717db82 commit c54964f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lightning/src/util/persist.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,11 @@ impl<ChannelSigner: EcdsaChannelSigner, K: KVStore + ?Sized> Persist<ChannelSign
261261
fn persist_new_channel(
262262
&self, funding_txo: OutPoint, monitor: &ChannelMonitor<ChannelSigner>,
263263
) -> chain::ChannelMonitorUpdateStatus {
264-
let key = format!("{}_{}", funding_txo.txid.to_string(), funding_txo.index);
264+
let monitor_name = MonitorName::from(funding_txo);
265265
match self.write(
266266
CHANNEL_MONITOR_PERSISTENCE_PRIMARY_NAMESPACE,
267267
CHANNEL_MONITOR_PERSISTENCE_SECONDARY_NAMESPACE,
268-
&key,
268+
monitor_name.as_str(),
269269
&monitor.encode(),
270270
) {
271271
Ok(()) => chain::ChannelMonitorUpdateStatus::Completed,
@@ -277,11 +277,11 @@ impl<ChannelSigner: EcdsaChannelSigner, K: KVStore + ?Sized> Persist<ChannelSign
277277
&self, funding_txo: OutPoint, _update: Option<&ChannelMonitorUpdate>,
278278
monitor: &ChannelMonitor<ChannelSigner>,
279279
) -> chain::ChannelMonitorUpdateStatus {
280-
let key = format!("{}_{}", funding_txo.txid.to_string(), funding_txo.index);
280+
let monitor_name = MonitorName::from(funding_txo);
281281
match self.write(
282282
CHANNEL_MONITOR_PERSISTENCE_PRIMARY_NAMESPACE,
283283
CHANNEL_MONITOR_PERSISTENCE_SECONDARY_NAMESPACE,
284-
&key,
284+
monitor_name.as_str(),
285285
&monitor.encode(),
286286
) {
287287
Ok(()) => chain::ChannelMonitorUpdateStatus::Completed,

0 commit comments

Comments
 (0)