Skip to content

Add ValidatorInfo to PeerContacts. #14454

Add ValidatorInfo to PeerContacts.

Add ValidatorInfo to PeerContacts. #14454

GitHub Actions / Clippy Report succeeded Jan 31, 2025 in 0s

Clippy Report

3 warnings

Details

Results

Message level Amount
Internal compiler error 0
Error 0
Warning 3
Note 0
Help 0

Versions

  • rustc 1.84.1 (e71f9a9a9 2025-01-27)
  • cargo 1.84.1 (66221abde 2024-11-19)
  • clippy 0.1.84 (e71f9a9a98 2025-01-27)

Annotations

Check warning on line 843 in network-libp2p/src/discovery/peer_contacts.rs

See this annotation in the file changed.

@github-actions github-actions / Clippy Report

using `clone` on type `PeerId` which implements the `Copy` trait

warning: using `clone` on type `PeerId` which implements the `Copy` trait
   --> network-libp2p/src/discovery/peer_contacts.rs:843:47
    |
843 |                         Err(_) => return Some(peer_id.clone()),
    |                                               ^^^^^^^^^^^^^^^ help: try dereferencing it: `*peer_id`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy

Check warning on line 826 in network-libp2p/src/discovery/peer_contacts.rs

See this annotation in the file changed.

@github-actions github-actions / Clippy Report

using `clone` on type `PeerId` which implements the `Copy` trait

warning: using `clone` on type `PeerId` which implements the `Copy` trait
   --> network-libp2p/src/discovery/peer_contacts.rs:826:33
    |
826 |                     return Some(peer_id.clone());
    |                                 ^^^^^^^^^^^^^^^ help: try dereferencing it: `*peer_id`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
    = note: `#[warn(clippy::clone_on_copy)]` on by default

Check warning on line 750 in network-libp2p/src/discovery/peer_contacts.rs

See this annotation in the file changed.

@github-actions github-actions / Clippy Report

using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`

warning: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
   --> network-libp2p/src/discovery/peer_contacts.rs:744:34
    |
744 |           contact.validator_info = self.validator_record_signer.as_ref().and_then(|callback| {
    |  __________________________________^
745 | |             let tagged_signed = (callback)(contact.peer_id(), contact.timestamp);
746 | |             Some(ValidatorInfo {
747 | |                 validator_address: tagged_signed.record.validator_address.clone(),
748 | |                 signature: tagged_signed.signature.clone(),
749 | |             })
750 | |         });
    | |__________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bind_instead_of_map
    = note: `#[warn(clippy::bind_instead_of_map)]` on by default
help: use `map` instead
    |
744 ~         contact.validator_info = self.validator_record_signer.as_ref().map(|callback| {
745 |             let tagged_signed = (callback)(contact.peer_id(), contact.timestamp);
746 ~             ValidatorInfo {
747 +                 validator_address: tagged_signed.record.validator_address.clone(),
748 +                 signature: tagged_signed.signature.clone(),
749 +             }
    |