Skip to content

Commit d56620d

Browse files
committed
f more comments
1 parent 56b58c8 commit d56620d

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
@@ -1094,11 +1094,19 @@ where
10941094
let monitor_key = monitor_name.to_string();
10951095
let update_name = UpdateName::from(update.update_id);
10961096
let primary = CHANNEL_MONITOR_UPDATE_PERSISTENCE_PRIMARY_NAMESPACE;
1097+
// Note that this is NOT an async function, but rather calls the *sync* KVStore
1098+
// write method, allowing it to do its queueing immediately, and then return a
1099+
// future for the completion of the write. This ensures monitor persistence
1100+
// ordering is preserved.
10971101
res_a = Some(self.kv_store
10981102
.write(primary, &monitor_key, update_name.as_str(), update.encode())
10991103
);
11001104
} else {
11011105
// We could write this update, but it meets criteria of our design that calls for a full monitor write.
1106+
// Note that this is NOT an async function, but rather calls the *sync* KVStore
1107+
// write method, allowing it to do its queueing immediately, and then return a
1108+
// future for the completion of the write. This ensures monitor persistence
1109+
// ordering is preserved. This, thus, must happen before any await we do below.
11021110
let write_fut = self.persist_new_channel(monitor_name, monitor);
11031111
let latest_update_id = monitor.get_latest_update_id();
11041112

@@ -1126,6 +1134,9 @@ where
11261134
res_c = Some(self.persist_new_channel(monitor_name, monitor));
11271135
}
11281136
async move {
1137+
// Complete any pending future(s). Note that to keep one return type we have to end
1138+
// with a single async move block that we return, rather than trying to return the
1139+
// individual futures themselves.
11291140
if let Some(a) = res_a {
11301141
a.await?;
11311142
}

0 commit comments

Comments
 (0)