Skip to content

Commit 41a718d

Browse files
committed
fix: add max limit to ws sub
1 parent 4c68e1d commit 41a718d

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

crates/cdk-axum/src/ws/subscribe.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ pub(crate) async fn handle(
1515
return Err(WsError::InvalidParams);
1616
}
1717

18+
let max_filters = context.state.mint.max_inputs();
19+
if params.filters.len() > max_filters {
20+
tracing::warn!(
21+
"WebSocket subscription request exceeds max filters limit: {} > {}",
22+
params.filters.len(),
23+
max_filters
24+
);
25+
return Err(WsError::InvalidParams);
26+
}
27+
1828
let mut subscription = context
1929
.state
2030
.mint

crates/cdk/src/mint/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,11 +475,19 @@ impl Mint {
475475
}
476476

477477
/// Localstore
478+
#[inline]
478479
pub fn localstore(&self) -> DynMintDatabase {
479480
Arc::clone(&self.localstore)
480481
}
481482

483+
/// Get the maximum number of inputs allowed per transaction
484+
#[inline]
485+
pub fn max_inputs(&self) -> usize {
486+
self.max_inputs
487+
}
488+
482489
/// Pub Sub manager
490+
#[inline]
483491
pub fn pubsub_manager(&self) -> Arc<PubSubManager> {
484492
Arc::clone(&self.pubsub_manager)
485493
}

0 commit comments

Comments
 (0)