Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
inetic committed Aug 30, 2023
1 parent eb88357 commit 770cf27
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 25 deletions.
5 changes: 2 additions & 3 deletions lib/src/network/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ impl Client {
break;
}
branch_to_reload = reload_index_rx.recv() => {
match branch_to_reload {
Ok(branch_to_reload) => self.reload_index(&branch_to_reload),
Err(_) => (),
if let Ok(branch_to_reload) = branch_to_reload {
self.reload_index(&branch_to_reload);
}
}
}
Expand Down
17 changes: 7 additions & 10 deletions lib/src/store/block_expiration_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,13 @@ async fn run_task(
let now = SystemTime::now();

if expires_at > now {
match expires_at.duration_since(now) {
Ok(duration) => {
select! {
_ = sleep(duration) => (),
_ = expiration_time_rx.changed() => {
continue;
}
if let Ok(duration) = expires_at.duration_since(now) {
select! {
_ = sleep(duration) => (),
_ = expiration_time_rx.changed() => {
continue;
}
}
Err(_) => (),
}

// Check it's still the oldest block.
Expand Down Expand Up @@ -398,11 +395,11 @@ mod test {

writer
.link_block(
&branch_id,
branch_id,
&rand::random(),
&block_id,
SingleBlockPresence::Present,
&write_keys,
write_keys,
)
.await
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion lib/src/store/leaf_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub(super) async fn set_missing_if_expired(
WHERE block_id = ? AND block_presence = ?",
)
.bind(SingleBlockPresence::Missing)
.bind(&block)
.bind(block)
.bind(SingleBlockPresence::Expired)
.execute(tx)
.await?;
Expand Down
17 changes: 6 additions & 11 deletions lib/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ impl Store {
}

pub async fn block_expiration(&self) -> Option<Duration> {
match &*self.block_expiration_tracker.read().await {
Some(tracker) => Some(tracker.block_expiration()),
None => None,
}
(*self.block_expiration_tracker.read().await).as_ref().map(|tracker| tracker.block_expiration())
}

/// Acquires a `Reader`
Expand Down Expand Up @@ -283,10 +280,8 @@ impl Reader {

let result = block::read(self.db(), id, buffer).await;

if matches!(result, Err(Error::BlockNotFound)) {
if self.set_as_missing_if_expired(id).await? {
block_tracker.require(*id);
}
if matches!(result, Err(Error::BlockNotFound)) && self.set_as_missing_if_expired(id).await? {
block_tracker.require(*id);
}

result
Expand All @@ -308,7 +303,7 @@ impl Reader {
return Ok(false);
}

let nodes: Vec<_> = leaf_node::load_parent_hashes(&mut tx, &block_id)
let nodes: Vec<_> = leaf_node::load_parent_hashes(&mut tx, block_id)
.try_collect()
.await?;

Expand Down Expand Up @@ -782,9 +777,9 @@ impl WriteTransaction {

for _ in 0..INNER_LAYER_COUNT {
for node in &nodes {
receive_filter.remove(self.db(), &node).await?;
receive_filter.remove(self.db(), node).await?;

let mut parents = inner_node::load_parent_hashes(self.db(), &node);
let mut parents = inner_node::load_parent_hashes(self.db(), node);

while let Some(parent) = parents.try_next().await? {
next_layer.insert(parent);
Expand Down

0 comments on commit 770cf27

Please sign in to comment.