feat: is_self_addr(): Employ the config cache to optimize for ConfiguredAddr passed

This commit is contained in:
iequidoo
2026-04-28 11:11:58 -03:00
committed by iequidoo
parent 804590c7f3
commit f20907d597

View File

@@ -944,6 +944,18 @@ impl Context {
/// Determine whether the specified addr maps to the/a self addr.
/// Returns `false` if no addresses are configured.
pub(crate) async fn is_self_addr(&self, addr: &str) -> Result<bool> {
// Employ the config cache to optimize for `ConfiguredAddr` passed.
if !addr.is_empty()
&& addr_cmp(
addr,
&self
.get_config(Config::ConfiguredAddr)
.await?
.unwrap_or_default(),
)
{
return Ok(true);
}
Ok(self
.get_all_self_addrs()
.await?