Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.

imp(discovery): clippy + cleanup#591

Closed
JannikSt wants to merge 1 commit into
developfrom
imp/discovery-cleanup
Closed

imp(discovery): clippy + cleanup#591
JannikSt wants to merge 1 commit into
developfrom
imp/discovery-cleanup

Conversation

@JannikSt
Copy link
Copy Markdown
Member

No description provided.

@JannikSt JannikSt force-pushed the imp/discovery-cleanup branch from 2a2ab5d to bc84a04 Compare June 25, 2025 11:01
@JannikSt JannikSt requested a review from Copilot June 25, 2025 11:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The PR cleans up code and enables stricter Clippy lints across multiple crates, modernizing syntax and improving performance.

  • Removes unnecessary clone() calls and replaces verbose match blocks with let-else patterns.
  • Optimizes Redis lookups in NodeStore using pipelining.
  • Configures workspace-level Clippy lint settings and refactors API routes for fewer allocations.

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/shared/src/web3/contracts/core/contract.rs Remove redundant clone() when parsing ABI JSON
crates/shared/src/security/auth_signature_middleware.rs Simplify error handling with let-else for signature recovery
crates/shared/src/p2p/client.rs Refactor signature parsing and message signing error propagation
crates/orchestrator/src/store/core/context.rs Eliminate unnecessary clone() when initializing metrics store
crates/discovery/src/store/node_store.rs Change String parameters to &str and optimize count_active_nodes_by_ip with Redis pipelining
crates/discovery/src/main.rs Simplify URL parsing with let-else and improve panic messages for contract build
crates/discovery/src/location_service.rs Replace expect with unwrap_or_else for HTTP client construction
crates/discovery/src/chainsync/sync.rs Convert run method from async to sync to streamline invocation
crates/discovery/src/api/server.rs Refactor health check logic to use if let instead of match
crates/discovery/src/api/routes/node.rs Reduce unnecessary cloning and streamline node registration flow
crates/discovery/src/api/routes/get_nodes.rs Improve node filtering algorithm and modernize error handling patterns
crates/discovery/Cargo.toml Add workspace lint configuration for Clippy
Cargo.toml Define workspace-level Clippy lint settings

Comment on lines +52 to +59
let pool_contract_id: U256 = match pool_id.parse::<U256>() {
Ok(id) => id,
Err(_) => {
return HttpResponse::BadRequest()
.json(ApiResponse::new(false, "Invalid pool ID format"));
}
};

Copy link

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] You parse pool_id twice (once to U256 and again to u32). Consider parsing once to u32 and converting to U256 using U256::from(parsed_id) to avoid duplication and improve readability.

Suggested change
let pool_contract_id: U256 = match pool_id.parse::<U256>() {
Ok(id) => id,
Err(_) => {
return HttpResponse::BadRequest()
.json(ApiResponse::new(false, "Invalid pool ID format"));
}
};

Copilot uses AI. Check for mistakes.
}
};

let pool_id: u32 = match pool_id.parse() {
Copy link

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Shadowing the pool_id variable (string → u32) may be confusing. Consider using a distinct name like parsed_pool_id for clarity.

Suggested change
let pool_id: u32 = match pool_id.parse() {
let parsed_pool_id: u32 = match pool_id.parse() {

Copilot uses AI. Check for mistakes.
.with_stake_manager()
.build()
.unwrap();
.unwrap_or_else(|_| panic!("Failed to build contracts"));
Copy link

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Include the original error in the panic message to aid debugging, e.g., unwrap_or_else(|e| panic!("Failed to build contracts: {e:?}")).

Suggested change
.unwrap_or_else(|_| panic!("Failed to build contracts"));
.unwrap_or_else(|e| panic!("Failed to build contracts: {e:?}"));

Copilot uses AI. Check for mistakes.
@JannikSt JannikSt closed this Jul 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants