Skip to content

Commit

Permalink
chore: fix up comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pepyakin authored and rphmeier committed Dec 10, 2024
1 parent 85b15e4 commit 30129dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 1 addition & 2 deletions nomt/src/merkle/seek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ impl Seeker {
None
}

/// Try to process the next I/O. Does not block the current thread. Returns `true` if
/// a completion was processed.
/// Try to process the next I/O. Does not block the current thread.
pub fn try_recv_page(&mut self, read_pass: &ReadPass<ShardIndex>) -> anyhow::Result<()> {
if let Some(completion) = self.page_loader.try_complete()? {
self.handle_completion(read_pass, completion);
Expand Down
15 changes: 10 additions & 5 deletions nomt/src/page_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ const CLEAR_BIT: u64 = 1 << 63;
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct PageDiff {
/// Each bit indicates whether the node at the corresponding index has changed.
/// Later bits are unused.
///
/// There are only effectively [`NODES_PER_PAGE`] (126) nodes per page. The last two bits are
/// reserved.
///
/// See [`CLEAR_BIT`].
changed_nodes: [u64; 2],
}

impl PageDiff {
/// Create a new page diff from bytes.
///
/// Returns `None` if any of unused bits are set to 1.
/// Returns `None` if any of reserved bits are set to 1.
pub fn from_bytes(bytes: [u8; 16]) -> Option<Self> {
let mut changed_nodes = [0u64; 2];
changed_nodes[0] = u64::from_le_bytes(bytes[0..8].try_into().unwrap());
Expand All @@ -28,8 +32,8 @@ impl PageDiff {
}

/// Note that some 32-byte slot in the page data has changed.
/// The acceptable range is 0..NODES_PER_PAGE.
/// Erase the clear bit.
///
/// The acceptable range is 0..NODES_PER_PAGE. Erases the clear bit.
pub fn set_changed(&mut self, slot_index: usize) {
assert!(slot_index < NODES_PER_PAGE);
let word = slot_index / 64;
Expand Down Expand Up @@ -89,7 +93,8 @@ impl PageDiff {
(self.changed_nodes[0].count_ones() + self.changed_nodes[1].count_ones()) as usize
}

/// Get raw bytes representing the PageDiff
/// Get raw bytes representing the PageDiff.
///
/// Panics if this is a cleared page-diff.
pub fn as_bytes(&self) -> [u8; 16] {
let mut bytes = [0u8; 16];
Expand Down

0 comments on commit 30129dc

Please sign in to comment.