From e63d179424b9bb128a9213f90926f18a083cfa01 Mon Sep 17 00:00:00 2001 From: Greg Heartsfield Date: Sat, 11 Feb 2023 13:26:08 -0600 Subject: [PATCH] fix: prevent loop when nip05 metadata channel closes --- src/error.rs | 2 ++ src/nip05.rs | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/error.rs b/src/error.rs index 0f87060..f931b92 100644 --- a/src/error.rs +++ b/src/error.rs @@ -62,6 +62,8 @@ pub enum Error { HexError(hex::FromHexError), #[error("Delegation parse error")] DelegationParseError, + #[error("Channel closed error")] + ChannelClosed, #[error("Unknown/Undocumented")] UnknownError, } diff --git a/src/nip05.rs b/src/nip05.rs index 4ba9763..f261e70 100644 --- a/src/nip05.rs +++ b/src/nip05.rs @@ -257,8 +257,15 @@ impl Verifier { // run a loop, restarting on failure loop { let res = self.run_internal().await; - if let Err(e) = res { + match res { + Err(Error::ChannelClosed) => { + // channel was closed, we are shutting down + return; + }, + Err(e) => { info!("error in verifier: {:?}", e); + }, + _ => {} } } } @@ -305,6 +312,7 @@ impl Verifier { } Err(tokio::sync::broadcast::error::RecvError::Closed) => { info!("metadata broadcast channel closed"); + return Err(Error::ChannelClosed); } } },