Skip to content

Commit d23181f

Browse files
committed
Remove unnecessary variable indirection in persist.rs
1 parent 98e6a8e commit d23181f

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

lightning/src/util/persist.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -821,8 +821,7 @@ where
821821
Vec<(BlockHash, ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>)>,
822822
io::Error,
823823
> {
824-
let primary = CHANNEL_MONITOR_NAMESPACE;
825-
let monitor_list = self.0.kv_store.list(primary, "").await?;
824+
let monitor_list = self.0.kv_store.list(CHANNEL_MONITOR_NAMESPACE, "").await?;
826825
let mut res = Vec::with_capacity(monitor_list.len());
827826
for monitor_key in monitor_list {
828827
let result =
@@ -1040,8 +1039,7 @@ where
10401039
Option<(BlockHash, ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>)>,
10411040
io::Error,
10421041
> {
1043-
let primary = CHANNEL_MONITOR_NAMESPACE;
1044-
let monitor_bytes = self.kv_store.read(primary, "", monitor_key).await?;
1042+
let monitor_bytes = self.kv_store.read(CHANNEL_MONITOR_NAMESPACE, "", monitor_key).await?;
10451043
let mut monitor_cursor = io::Cursor::new(monitor_bytes);
10461044
// Discard the sentinel bytes if found.
10471045
if monitor_cursor.get_ref().starts_with(MONITOR_UPDATING_PERSISTER_PREPEND_SENTINEL) {
@@ -1099,8 +1097,7 @@ where
10991097
}
11001098

11011099
async fn cleanup_stale_updates(&self, lazy: bool) -> Result<(), io::Error> {
1102-
let primary = CHANNEL_MONITOR_NAMESPACE;
1103-
let monitor_keys = self.kv_store.list(primary, "").await?;
1100+
let monitor_keys = self.kv_store.list(CHANNEL_MONITOR_NAMESPACE, "").await?;
11041101
for monitor_key in monitor_keys {
11051102
let monitor_name = MonitorName::from_str(&monitor_key)?;
11061103
let maybe_monitor = self.maybe_read_monitor(&monitor_name, &monitor_key).await?;
@@ -1119,13 +1116,15 @@ where
11191116
async fn cleanup_stale_updates_for_monitor_to(
11201117
&self, monitor_key: &str, latest_update_id: u64, lazy: bool,
11211118
) -> Result<(), io::Error> {
1122-
let primary = MONITOR_UPDATE_NAMESPACE;
1123-
let updates = self.kv_store.list(primary, monitor_key).await?;
1119+
let updates = self.kv_store.list(MONITOR_UPDATE_NAMESPACE, monitor_key).await?;
11241120
for update in updates {
11251121
let update_name = UpdateName::new(update)?;
11261122
// if the update_id is lower than the stored monitor, delete
11271123
if update_name.0 <= latest_update_id {
1128-
self.kv_store.remove(primary, monitor_key, update_name.as_str(), lazy).await?;
1124+
self
1125+
.kv_store
1126+
.remove(MONITOR_UPDATE_NAMESPACE, monitor_key, update_name.as_str(), lazy)
1127+
.await?;
11291128
}
11301129
}
11311130
Ok(())
@@ -1150,8 +1149,7 @@ where
11501149
// Note that this is NOT an async function, but rather calls the *sync* KVStore write
11511150
// method, allowing it to do its queueing immediately, and then return a future for the
11521151
// completion of the write. This ensures monitor persistence ordering is preserved.
1153-
let primary = CHANNEL_MONITOR_NAMESPACE;
1154-
self.kv_store.write(primary, "", monitor_key.as_str(), monitor_bytes)
1152+
self.kv_store.write(CHANNEL_MONITOR_NAMESPACE, "", monitor_key.as_str(), monitor_bytes)
11551153
}
11561154

11571155
fn update_persisted_channel<'a, ChannelSigner: EcdsaChannelSigner + 'a>(
@@ -1172,13 +1170,12 @@ where
11721170
if persist_update {
11731171
let monitor_key = monitor_name.to_string();
11741172
let update_name = UpdateName::from(update.update_id);
1175-
let primary = MONITOR_UPDATE_NAMESPACE;
11761173
// Note that this is NOT an async function, but rather calls the *sync* KVStore
11771174
// write method, allowing it to do its queueing immediately, and then return a
11781175
// future for the completion of the write. This ensures monitor persistence
11791176
// ordering is preserved.
11801177
res_a = Some(self.kv_store.write(
1181-
primary,
1178+
MONITOR_UPDATE_NAMESPACE,
11821179
&monitor_key,
11831180
update_name.as_str(),
11841181
update.encode(),
@@ -1248,8 +1245,7 @@ where
12481245
Ok(()) => {},
12491246
Err(_e) => return,
12501247
};
1251-
let primary = CHANNEL_MONITOR_NAMESPACE;
1252-
let _ = self.kv_store.remove(primary, "", &monitor_key, true).await;
1248+
let _ = self.kv_store.remove(CHANNEL_MONITOR_NAMESPACE, "", &monitor_key, true).await;
12531249
}
12541250

12551251
// Cleans up monitor updates for given monitor in range `start..=end`.

0 commit comments

Comments
 (0)