Skip to content

Commit

Permalink
Clean up clippy warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
aterentic-ethernal committed Aug 11, 2023
1 parent 4ff443f commit 0e6b747
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async fn run(error_sender: Sender<anyhow::Error>) -> Result<()> {
db: db.clone(),
cfg: cfg.clone(),
counter: counter.clone(),
version: format!("v{}", clap::crate_version!().to_string()),
version: format!("v{}", clap::crate_version!()),
network_version: EXPECTED_NETWORK_VERSION.to_string(),
};

Expand Down
7 changes: 3 additions & 4 deletions src/network/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl Client {

// Since callers ignores DHT errors, debug logs are used to observe DHT behavior.
// Return type assumes that cell is not found in case when error is present.
async fn fetch_cell_from_dht(&self, block_number: u32, position: &Position) -> Option<Cell> {
async fn fetch_cell_from_dht(&self, block_number: u32, position: Position) -> Option<Cell> {
let reference = position.reference(block_number);
let record_key = Key::from(reference.as_bytes().to_vec());

Expand All @@ -207,7 +207,6 @@ impl Client {
return None;
};

let position = position.clone();
Some(Cell { position, content })
},
Err(error) => {
Expand Down Expand Up @@ -252,7 +251,7 @@ impl Client {
let mut cells = Vec::<Option<Cell>>::with_capacity(positions.len());

for positions in positions.chunks(self.dht_parallelization_limit) {
let fetch = |position| self.fetch_cell_from_dht(block_number, position);
let fetch = |&position| self.fetch_cell_from_dht(block_number, position);
let results = join_all(positions.iter().map(fetch)).await;
cells.extend(results.into_iter().collect::<Vec<_>>());
}
Expand All @@ -261,7 +260,7 @@ impl Client {
.iter()
.zip(positions)
.filter(|(cell, _)| cell.is_none())
.map(|(_, position)| position.clone())
.map(|(_, &position)| position)
.collect::<Vec<_>>();

let fetched = cells.into_iter().flatten().collect();
Expand Down
2 changes: 1 addition & 1 deletion src/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub fn init(
let upgraded_relay_transport = relay_client_transport
.upgrade(Version::V1Lazy)
.authenticate(NoiseConfig::xx(noise_keys).into_authenticated())

Check warning on line 100 in src/network/mod.rs

View workflow job for this annotation

GitHub Actions / build_and_test

use of deprecated struct `libp2p::libp2p_noise::NoiseConfig`: Use `libp2p_noise::Config` instead. All other handshake patterns are deprecated and will be removed.
.multiplex(libp2p::yamux::YamuxConfig::default());
.multiplex(libp2p::yamux::Config::default());
// relay transport only handles listening and dialing on relayed [`Multiaddr`]
// and depends on other transport to do the actual transmission of data, we have to combine the two
let transport =
Expand Down
11 changes: 4 additions & 7 deletions src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ pub async fn get_header_by_block_number(
/// Generates random cell positions for sampling
pub fn generate_random_cells(dimensions: Dimensions, cell_count: u32) -> Vec<Position> {
let max_cells = dimensions.extended_size();
let count = if max_cells < cell_count.into() {
let count = if max_cells < cell_count {
debug!("Max cells count {max_cells} is lesser than cell_count {cell_count}");
max_cells
} else {
cell_count.into()
cell_count
};
let mut rng = thread_rng();
let mut indices = HashSet::new();
Expand Down Expand Up @@ -157,10 +157,7 @@ pub async fn get_kate_proof(
Ok(positions
.iter()
.zip(i)
.map(|(position, &content)| Cell {
position: position.clone(),
content,
})
.map(|(&position, &content)| Cell { position, content })
.collect::<Vec<_>>())
}

Expand Down Expand Up @@ -209,7 +206,7 @@ impl ExpectedVersion<'_> {
/// Since runtime `spec_version` can be changed with runtime upgrade, `spec_version` is removed.
/// NOTE: Runtime compatiblity check is currently not implemented.
pub fn matches(&self, node_version: String, spec_name: String) -> bool {
node_version.starts_with(&self.version) && self.spec_name == spec_name
node_version.starts_with(self.version) && self.spec_name == spec_name
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl From<&RuntimeConfig> for LightClientConfig {
dht_parallelization_limit: val.dht_parallelization_limit,
query_proof_rpc_parallel_tasks: val.query_proof_rpc_parallel_tasks,
block_processing_delay: Delay(block_processing_delay),
block_matrix_partition: val.block_matrix_partition.clone(),
block_matrix_partition: val.block_matrix_partition,
disable_proof_verification: val.disable_proof_verification,
max_cells_per_rpc: val.max_cells_per_rpc.unwrap_or(30),
ttl: val.kad_record_ttl,
Expand Down

0 comments on commit 0e6b747

Please sign in to comment.