mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-30 01:28:21 -05:00
fix: check if value is bool (#3708)
This commit is contained in:
@@ -104,8 +104,8 @@ pub enum Params {
|
||||
None,
|
||||
/// Log parameters.
|
||||
Logs(Box<Filter>),
|
||||
/// New pending transaction parameters.
|
||||
NewPendingTransactions(bool),
|
||||
/// Boolean parameter for new pending transactions.
|
||||
Bool(bool),
|
||||
}
|
||||
|
||||
impl Serialize for Params {
|
||||
@@ -116,7 +116,7 @@ impl Serialize for Params {
|
||||
match self {
|
||||
Params::None => (&[] as &[serde_json::Value]).serialize(serializer),
|
||||
Params::Logs(logs) => logs.serialize(serializer),
|
||||
Params::NewPendingTransactions(full) => full.serialize(serializer),
|
||||
Params::Bool(full) => full.serialize(serializer),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,6 +132,10 @@ impl<'a> Deserialize<'a> for Params {
|
||||
return Ok(Params::None)
|
||||
}
|
||||
|
||||
if let Some(val) = v.as_bool() {
|
||||
return Ok(Params::Bool(val))
|
||||
}
|
||||
|
||||
serde_json::from_value(v)
|
||||
.map(|f| Params::Logs(Box::new(f)))
|
||||
.map_err(|e| D::Error::custom(format!("Invalid Pub-Sub parameters: {e}")))
|
||||
|
||||
@@ -124,7 +124,7 @@ where
|
||||
SubscriptionKind::NewPendingTransactions => {
|
||||
if let Some(params) = params {
|
||||
match params {
|
||||
Params::NewPendingTransactions(true) => {
|
||||
Params::Bool(true) => {
|
||||
// full transaction objects requested
|
||||
let stream = pubsub.full_pending_transaction_stream().map(|tx| {
|
||||
EthSubscriptionResult::FullTransaction(Box::new(
|
||||
@@ -135,7 +135,7 @@ where
|
||||
});
|
||||
return pipe_from_stream(accepted_sink, stream).await
|
||||
}
|
||||
Params::NewPendingTransactions(false) | Params::None => {
|
||||
Params::Bool(false) | Params::None => {
|
||||
// only hashes requested
|
||||
}
|
||||
Params::Logs(_) => {
|
||||
|
||||
Reference in New Issue
Block a user