Skip to content

Commit 12c60ae

Browse files
committed
cleanup
1 parent d99e5a5 commit 12c60ae

3 files changed

Lines changed: 22 additions & 28 deletions

File tree

storage/src/journal/authenticated.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,10 @@ where
675675

676676
/// Durably persist the journal, ensuring no recovery is required on startup.
677677
pub async fn sync(&mut self) -> Result<(), Error<F>> {
678-
self.journal.sync().await.map_err(Error::Journal)?;
679-
self.merkle.sync().await.map_err(Error::Merkle)?;
678+
try_join!(
679+
self.journal.sync().map_err(Error::Journal),
680+
self.merkle.sync().map_err(Error::Merkle),
681+
)?;
680682
Ok(())
681683
}
682684
}

storage/src/merkle/persisted/full.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
//!
77
//! This module is generic over [`Family`], so it works for both MMR and MMB.
88
9-
#[allow(unused_imports)]
10-
use crate::journal::contiguous::Reader as _;
119
use crate::{
1210
journal::{
1311
contiguous::{

storage/src/metadata/storage.rs

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ impl<E: Context, K: Span, V: Codec> Metadata<E, K, V> {
227227
// Mark key as modified.
228228
//
229229
// We need to mark both blobs as modified because we may need to update both files.
230-
let state = &mut self.state;
231-
state.blobs[state.cursor].modified.insert(key.clone());
232-
state.blobs[1 - state.cursor].modified.insert(key.clone());
230+
let cursor = self.state.cursor;
231+
self.state.blobs[cursor].modified.insert(key.clone());
232+
self.state.blobs[1 - cursor].modified.insert(key.clone());
233233

234234
Some(value)
235235
}
@@ -241,8 +241,7 @@ impl<E: Context, K: Span, V: Codec> Metadata<E, K, V> {
241241
self.map.clear();
242242

243243
// Mark key order as changed
244-
let state = &mut self.state;
245-
state.key_order_changed = state.next_version;
244+
self.state.key_order_changed = self.state.next_version;
246245
self.keys.set(0);
247246
}
248247

@@ -258,12 +257,12 @@ impl<E: Context, K: Span, V: Codec> Metadata<E, K, V> {
258257
// Mark key as modified.
259258
//
260259
// We need to mark both blobs as modified because we may need to update both files.
261-
let state = &mut self.state;
262260
if previous.is_some() {
263-
state.blobs[state.cursor].modified.insert(key.clone());
264-
state.blobs[1 - state.cursor].modified.insert(key);
261+
let cursor = self.state.cursor;
262+
self.state.blobs[cursor].modified.insert(key.clone());
263+
self.state.blobs[1 - cursor].modified.insert(key);
265264
} else {
266-
state.key_order_changed = state.next_version;
265+
self.state.key_order_changed = self.state.next_version;
267266
}
268267
let _ = self.keys.try_set(self.map.len());
269268
previous
@@ -307,8 +306,7 @@ impl<E: Context, K: Span, V: Codec> Metadata<E, K, V> {
307306

308307
// Mark key as modified.
309308
if past.is_some() {
310-
let state = &mut self.state;
311-
state.key_order_changed = state.next_version;
309+
self.state.key_order_changed = self.state.next_version;
312310
}
313311
let _ = self.keys.try_set(self.map.len());
314312

@@ -329,38 +327,35 @@ impl<E: Context, K: Span, V: Codec> Metadata<E, K, V> {
329327

330328
// If the number of keys has changed, mark the key order as changed
331329
if new_len != old_len {
332-
let state = &mut self.state;
333-
state.key_order_changed = state.next_version;
330+
self.state.key_order_changed = self.state.next_version;
334331
let _ = self.keys.try_set(self.map.len());
335332
}
336333
}
337334

338335
/// Atomically commit the current state of [Metadata].
339336
pub async fn sync(&mut self) -> Result<(), Error> {
340-
let state = &mut self.state;
341-
342337
// Extract values we need
343-
let cursor = state.cursor;
344-
let next_version = state.next_version;
345-
let key_order_changed = state.key_order_changed;
338+
let cursor = self.state.cursor;
339+
let next_version = self.state.next_version;
340+
let key_order_changed = self.state.key_order_changed;
346341

347342
// Compute next version.
348343
//
349344
// While it is possible that extremely high-frequency updates to metadata could cause an
350345
// eventual overflow of version, syncing once per millisecond would overflow in 584,942,417
351346
// years.
352-
let past_version = state.blobs[cursor].version;
347+
let past_version = self.state.blobs[cursor].version;
353348
let next_next_version = next_version.checked_add(1).expect("version overflow");
354349

355350
// Get target blob (the one we will modify)
356351
let target_cursor = 1 - cursor;
357352

358353
// Update the state.
359-
state.cursor = target_cursor;
360-
state.next_version = next_next_version;
354+
self.state.cursor = target_cursor;
355+
self.state.next_version = next_next_version;
361356

362357
// Get a mutable reference to the target blob.
363-
let target = &mut state.blobs[target_cursor];
358+
let target = &mut self.state.blobs[target_cursor];
364359

365360
// Determine if we can overwrite existing data in place, and prepare the list of data to
366361
// write in that event.
@@ -450,8 +445,7 @@ impl<E: Context, K: Span, V: Codec> Metadata<E, K, V> {
450445

451446
/// Remove the underlying blobs for this [Metadata].
452447
pub async fn destroy(self) -> Result<(), Error> {
453-
let state = self.state;
454-
for (i, wrapper) in state.blobs.into_iter().enumerate() {
448+
for (i, wrapper) in self.state.blobs.into_iter().enumerate() {
455449
drop(wrapper.blob);
456450
self.context
457451
.remove(&self.partition, Some(BLOB_NAMES[i]))

0 commit comments

Comments
 (0)