mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-27 08:08:15 -05:00
feat: fn that replaces and merges network module's endpoints (#16619)
Signed-off-by: Aliaksei Misiukevich <taberlick@gmail.com> Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
committed by
GitHub
parent
f6dec71dcf
commit
0848739717
@@ -1943,6 +1943,54 @@ impl TransportRpcModules {
|
||||
self.replace_ipc(other)?;
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
/// Adds or replaces given [`Methods`] in http module.
|
||||
///
|
||||
/// Returns `true` if the methods were replaced or added, `false` otherwise.
|
||||
pub fn add_or_replace_http(
|
||||
&mut self,
|
||||
other: impl Into<Methods>,
|
||||
) -> Result<bool, RegisterMethodError> {
|
||||
let other = other.into();
|
||||
self.remove_http_methods(other.method_names());
|
||||
self.merge_http(other)
|
||||
}
|
||||
|
||||
/// Adds or replaces given [`Methods`] in ws module.
|
||||
///
|
||||
/// Returns `true` if the methods were replaced or added, `false` otherwise.
|
||||
pub fn add_or_replace_ws(
|
||||
&mut self,
|
||||
other: impl Into<Methods>,
|
||||
) -> Result<bool, RegisterMethodError> {
|
||||
let other = other.into();
|
||||
self.remove_ws_methods(other.method_names());
|
||||
self.merge_ws(other)
|
||||
}
|
||||
|
||||
/// Adds or replaces given [`Methods`] in ipc module.
|
||||
///
|
||||
/// Returns `true` if the methods were replaced or added, `false` otherwise.
|
||||
pub fn add_or_replace_ipc(
|
||||
&mut self,
|
||||
other: impl Into<Methods>,
|
||||
) -> Result<bool, RegisterMethodError> {
|
||||
let other = other.into();
|
||||
self.remove_ipc_methods(other.method_names());
|
||||
self.merge_ipc(other)
|
||||
}
|
||||
|
||||
/// Adds or replaces given [`Methods`] in all configured network modules.
|
||||
pub fn add_or_replace_configured(
|
||||
&mut self,
|
||||
other: impl Into<Methods>,
|
||||
) -> Result<(), RegisterMethodError> {
|
||||
let other = other.into();
|
||||
self.add_or_replace_http(other.clone())?;
|
||||
self.add_or_replace_ws(other.clone())?;
|
||||
self.add_or_replace_ipc(other)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the methods installed in the given module that match the given filter.
|
||||
|
||||
Reference in New Issue
Block a user