Skip to content

Commit ce82e6a

Browse files
fix: resolve clippy, fmt, and build issues
- Remove unused HashMap import from server/mod.rs - Fix DelegateOp handler to use DashMap API directly (no .read() needed) - Update tuple destructuring to use AttestedContract struct fields - Apply cargo fmt formatting fixes Co-authored-by: nacho.d.g <iduartgomez@users.noreply.github.com>
1 parent 618cc63 commit ce82e6a

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

crates/core/src/client_events/websocket.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ async fn websocket_commands(
293293
let auth_and_instance = if let Some(token) = auth_token.as_ref() {
294294
// Only collect and log map contents when trace is enabled
295295
if tracing::enabled!(tracing::Level::TRACE) {
296-
let map_contents: Vec<_> = attested_contracts.iter().map(|e| e.key().clone()).collect();
296+
let map_contents: Vec<_> =
297+
attested_contracts.iter().map(|e| e.key().clone()).collect();
297298
tracing::trace!(?token, "attested_contracts map keys: {:?}", map_contents);
298299
}
299300

crates/core/src/server/mod.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pub(crate) mod errors;
1111
pub(crate) mod http_gateway;
1212
pub(crate) mod path_handlers;
1313

14-
use std::collections::HashMap;
1514
use std::net::SocketAddr;
1615
use std::sync::Arc;
1716
use std::time::{Duration, Instant};
@@ -139,10 +138,8 @@ pub mod local_node {
139138
ClientRequest::DelegateOp(op) => {
140139
let attested_contract = token.and_then(|token| {
141140
gw.attested_contracts
142-
.read()
143-
.map(|guard| guard.get(&token).cloned().map(|(t, _, _)| t))
144-
.ok()
145-
.flatten()
141+
.get(&token)
142+
.map(|entry| entry.contract_id.clone())
146143
});
147144
executor.delegate_request(op, attested_contract.as_ref())
148145
}
@@ -151,14 +148,10 @@ pub mod local_node {
151148
tracing::info!("disconnecting cause: {cause}");
152149
}
153150
// fixme: token must live for a bit to allow reconnections
154-
if let Some(rm_token) = gw
155-
.attested_contracts
156-
.iter()
157-
.find_map(|entry| {
158-
let (k, attested) = entry.pair();
159-
(attested.client_id == id).then(|| k.clone())
160-
})
161-
{
151+
if let Some(rm_token) = gw.attested_contracts.iter().find_map(|entry| {
152+
let (k, attested) = entry.pair();
153+
(attested.client_id == id).then(|| k.clone())
154+
}) {
162155
gw.attested_contracts.remove(&rm_token);
163156
}
164157
continue;

0 commit comments

Comments
 (0)