mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add contains fns to transport rpc modules (#12593)
This commit is contained in:
@ -1934,6 +1934,26 @@ impl TransportRpcModuleConfig {
|
||||
self.config.as_ref()
|
||||
}
|
||||
|
||||
/// Returns true if the given module is configured for any transport.
|
||||
pub fn contains_any(&self, module: &RethRpcModule) -> bool {
|
||||
self.contains_http(module) || self.contains_ws(module) || self.contains_ipc(module)
|
||||
}
|
||||
|
||||
/// Returns true if the given module is configured for the http transport.
|
||||
pub fn contains_http(&self, module: &RethRpcModule) -> bool {
|
||||
self.http.as_ref().map_or(false, |http| http.contains(module))
|
||||
}
|
||||
|
||||
/// Returns true if the given module is configured for the ws transport.
|
||||
pub fn contains_ws(&self, module: &RethRpcModule) -> bool {
|
||||
self.ws.as_ref().map_or(false, |ws| ws.contains(module))
|
||||
}
|
||||
|
||||
/// Returns true if the given module is configured for the ipc transport.
|
||||
pub fn contains_ipc(&self, module: &RethRpcModule) -> bool {
|
||||
self.ipc.as_ref().map_or(false, |ipc| ipc.contains(module))
|
||||
}
|
||||
|
||||
/// Ensures that both http and ws are configured and that they are configured to use the same
|
||||
/// port.
|
||||
fn ensure_ws_http_identical(&self) -> Result<(), WsHttpSamePortError> {
|
||||
|
||||
@ -140,6 +140,15 @@ impl RpcModuleSelection {
|
||||
(None, None) => true,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if the selection contains the given module.
|
||||
pub fn contains(&self, module: &RethRpcModule) -> bool {
|
||||
match self {
|
||||
Self::All => true,
|
||||
Self::Standard => Self::STANDARD_MODULES.contains(module),
|
||||
Self::Selection(s) => s.contains(module),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&HashSet<RethRpcModule>> for RpcModuleSelection {
|
||||
|
||||
Reference in New Issue
Block a user