Skip to content

Commit dbca0d2

Browse files
committed
feat: is_self_addr(): Employ the config cache to optimize for ConfiguredAddr passed
1 parent b806efa commit dbca0d2

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/config.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,18 @@ impl Context {
944944
/// Determine whether the specified addr maps to the/a self addr.
945945
/// Returns `false` if no addresses are configured.
946946
pub(crate) async fn is_self_addr(&self, addr: &str) -> Result<bool> {
947+
// Employ the config cache to optimize for `ConfiguredAddr` passed.
948+
if !addr.is_empty()
949+
&& addr_cmp(
950+
addr,
951+
&self
952+
.get_config(Config::ConfiguredAddr)
953+
.await?
954+
.unwrap_or_default(),
955+
)
956+
{
957+
return Ok(true);
958+
}
947959
Ok(self
948960
.get_all_self_addrs()
949961
.await?

0 commit comments

Comments
 (0)