Skip to content

Commit 4324dce

Browse files
committed
f more comments
1 parent 216de6a commit 4324dce

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lightning/src/util/persist.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,10 @@ where
10851085
if persist_update {
10861086
let monitor_key = monitor_name.to_string();
10871087
let update_name = UpdateName::from(update.update_id);
1088+
// Note that this is NOT an async function, but rather calls the *sync* KVStore
1089+
// write method, allowing it to do its queueing immediately, and then return a
1090+
// future for the completion of the write. This ensures monitor persistence
1091+
// ordering is preserved.
10881092
res_a = Some(self.kv_store.write(
10891093
CHANNEL_MONITOR_UPDATE_PERSISTENCE_PRIMARY_NAMESPACE,
10901094
monitor_key.as_str(),
@@ -1093,6 +1097,10 @@ where
10931097
));
10941098
} else {
10951099
// We could write this update, but it meets criteria of our design that calls for a full monitor write.
1100+
// Note that this is NOT an async function, but rather calls the *sync* KVStore
1101+
// write method, allowing it to do its queueing immediately, and then return a
1102+
// future for the completion of the write. This ensures monitor persistence
1103+
// ordering is preserved. This, thus, must happen before any await we do below.
10961104
let write_fut = self.persist_new_channel(monitor_name, monitor);
10971105
let latest_update_id = monitor.get_latest_update_id();
10981106

@@ -1120,6 +1128,9 @@ where
11201128
res_c = Some(self.persist_new_channel(monitor_name, monitor));
11211129
}
11221130
async move {
1131+
// Complete any pending future(s). Note that to keep one return type we have to end
1132+
// with a single async move block that we return, rather than trying to return the
1133+
// individual futures themselves.
11231134
if let Some(a) = res_a {
11241135
a.await?;
11251136
}

0 commit comments

Comments
 (0)