From c4f1dcb4c621b5bcf1e25ce1b2e7981bf9842096 Mon Sep 17 00:00:00 2001 From: bsbds <69835502+bsbds@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:37:21 +0800 Subject: [PATCH] fix: remove check_members This check is not necessary, the urls are allowed to be empty before publish Signed-off-by: bsbds <69835502+bsbds@users.noreply.github.com> --- crates/curp/src/client/unary.rs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/crates/curp/src/client/unary.rs b/crates/curp/src/client/unary.rs index 7c6dc488f..2acf6658a 100644 --- a/crates/curp/src/client/unary.rs +++ b/crates/curp/src/client/unary.rs @@ -270,20 +270,6 @@ impl ClientApi for Unary { /// Send fetch cluster requests to all servers /// Note: The fetched cluster may still be outdated if `linearizable` is false async fn fetch_cluster(&self, linearizable: bool) -> Result { - /// Checks the member list, returns `true` if all member has been published - fn check_members(members: &[Member]) -> bool { - if members.is_empty() { - return false; - } - for member in members { - if member.client_urls.is_empty() { - debug!("new node {} not published yet", member.id()); - return false; - } - } - true - } - let timeout = self.config.wait_synced_timeout; if !linearizable { // firstly, try to fetch the local server @@ -344,14 +330,14 @@ impl ClientApi for Unary { match max_term.cmp(&inner.term) { Ordering::Less => { max_term = inner.term; - if check_members(&inner.members) { + if !inner.members.is_empty() { res = Some(inner); } // reset ok count to 1 ok_cnt = 1; } Ordering::Equal => { - if check_members(&inner.members) { + if !inner.members.is_empty() { res = Some(inner); } ok_cnt += 1;