Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pmnoxx committed Dec 22, 2021
1 parent 2f7261f commit 8772d29
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions chain/chunks/src/chunk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,8 @@ impl EncodedChunksCache {
&& height <= self.largest_seen_height + MAX_HEIGHTS_AHEAD
{
let prev_block_hash = header.prev_block_hash();
let mut block_hash_to_chunk_headers = self
.block_hash_to_chunk_headers
.cache_remove(&prev_block_hash)
.unwrap_or_else(HashMap::new);
let mut block_hash_to_chunk_headers =
self.block_hash_to_chunk_headers.cache_remove(&prev_block_hash).unwrap_or_default();
block_hash_to_chunk_headers.insert(shard_id, header);
self.block_hash_to_chunk_headers
.cache_set(prev_block_hash, block_hash_to_chunk_headers);
Expand All @@ -192,7 +190,7 @@ impl EncodedChunksCache {
&mut self,
prev_block_hash: &CryptoHash,
) -> HashMap<ShardId, ShardChunkHeader> {
self.block_hash_to_chunk_headers.cache_remove(prev_block_hash).unwrap_or_else(HashMap::new)
self.block_hash_to_chunk_headers.cache_remove(prev_block_hash).unwrap_or_default()
}

/// Returns number of chunks that are ready to be included in the next block
Expand Down
2 changes: 1 addition & 1 deletion chain/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ impl Client {
}
}
let mut entry =
self.pending_approvals.cache_remove(&approval.inner).unwrap_or_else(HashMap::new);
self.pending_approvals.cache_remove(&approval.inner).unwrap_or_default();
entry.insert(approval.account_id.clone(), (approval.clone(), approval_type));
self.pending_approvals.cache_set(approval.inner.clone(), entry);
}
Expand Down

0 comments on commit 8772d29

Please # to comment.