Skip to content

Commit

Permalink
Apply clippy fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Litchi Pi <litchi.pi@proton.me>
  • Loading branch information
litchipi committed May 24, 2023
1 parent 6e746e7 commit d9ea432
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl PropagationThread {
}
}
for peer_id in peers_connected {
if !cache_write.blocks_known_by_peer.get(&peer_id).is_some() {
if cache_write.blocks_known_by_peer.get(&peer_id).is_none() {
//TODO: Change to detect the connection before
cache_write.blocks_known_by_peer.insert(
peer_id,
Expand Down
10 changes: 5 additions & 5 deletions massa-protocol-worker/src/handlers/block_handler/retrieval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,10 @@ impl RetrievalThread {
// check endorsement signature if not already checked
{
let read_cache = self.endorsement_cache.read();
if !read_cache
if read_cache
.checked_endorsements
.peek(&endorsement_id)
.is_some()
.is_none()
{
new_endorsements.insert(endorsement_id, endorsement);
}
Expand Down Expand Up @@ -1031,12 +1031,12 @@ impl RetrievalThread {
};

// Check operation signature only if not already checked.
if !self
if self
.operation_cache
.read()
.checked_operations
.peek(&operation_id)
.is_some()
.is_none()
{
// check signature if the operation wasn't in `checked_operation`
new_operations.insert(operation_id, operation);
Expand Down Expand Up @@ -1123,7 +1123,7 @@ impl RetrievalThread {
}
// Add new peers
for peer_id in peers_connected {
if !cache_write.blocks_known_by_peer.get(&peer_id).is_some() {
if cache_write.blocks_known_by_peer.get(&peer_id).is_none() {
//TODO: Change to detect the connection before
cache_write.blocks_known_by_peer.insert(
peer_id.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ impl PropagationThread {
let peer_connected =
self.active_connections.get_peer_ids_connected();
for peer_id in &peer_connected {
if !cache_write
if cache_write
.endorsements_known_by_peer
.get(peer_id)
.is_some()
.is_none()
{
cache_write.endorsements_known_by_peer.insert(
peer_id.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ impl RetrievalThread {
// check endorsement signature if not already checked
{
let read_cache = self.cache.read();
if !read_cache
if read_cache
.checked_endorsements
.peek(&endorsement_id)
.is_some()
.is_none()
{
new_endorsements.insert(endorsement_id, endorsement);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl PropagationThread {

// Add new potential peers
for peer_id in peers_connected {
if !cache_write.ops_known_by_peer.get(&peer_id).is_some() {
if cache_write.ops_known_by_peer.get(&peer_id).is_none() {
cache_write.ops_known_by_peer.insert(
peer_id.clone(),
LruMap::new(ByLength::new(
Expand All @@ -126,7 +126,7 @@ impl PropagationThread {
let ops = cache_write.ops_known_by_peer.peek_mut(&peer_id).unwrap();
let new_ops: Vec<OperationId> = operation_ids
.iter()
.filter(|id| !ops.peek(&id.prefix()).is_some())
.filter(|id| ops.peek(&id.prefix()).is_none())
.copied()
.collect();
if !new_ops.is_empty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ impl RetrievalThread {
received_ids.insert(operation_id);

// Check operation signature only if not already checked.
if !self
if self
.cache
.read()
.checked_operations
.peek(&operation_id)
.is_some()
.is_none()
{
// check signature if the operation wasn't in `checked_operation`
new_operations.insert(operation_id, operation);
Expand Down Expand Up @@ -338,7 +338,7 @@ impl RetrievalThread {
// filter out the operations that we already know about
{
let cache_read = self.cache.read();
op_batch.retain(|prefix| !cache_read.checked_operations_prefix.peek(prefix).is_some());
op_batch.retain(|prefix| cache_read.checked_operations_prefix.peek(prefix).is_none());
}

let mut ask_set = OperationPrefixIds::with_capacity(op_batch.len());
Expand Down

0 comments on commit d9ea432

Please sign in to comment.