diff options
author | Alex Auvolat <alex@adnab.me> | 2023-11-14 13:06:16 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-11-14 13:12:32 +0100 |
commit | 1aab1f4e688ebc3f3adcb41c817c16c688a3291c (patch) | |
tree | cf006db1b3aeb6ebff8d976aee33469ffabe75f2 /src/rpc/layout/history.rs | |
parent | 8e292e06b3fde1d3b5b019a26eabd4f0d9ac22c3 (diff) | |
download | garage-1aab1f4e688ebc3f3adcb41c817c16c688a3291c.tar.gz garage-1aab1f4e688ebc3f3adcb41c817c16c688a3291c.zip |
layout: refactoring of all_nodes
Diffstat (limited to 'src/rpc/layout/history.rs')
-rw-r--r-- | src/rpc/layout/history.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/rpc/layout/history.rs b/src/rpc/layout/history.rs index 877ad3a7..69348873 100644 --- a/src/rpc/layout/history.rs +++ b/src/rpc/layout/history.rs @@ -60,6 +60,21 @@ impl LayoutHistory { (self.current().version, self.all_ack(), self.min_stored()) } + pub fn all_nodes(&self) -> Cow<'_, [Uuid]> { + // TODO: cache this + if self.versions.len() == 1 { + self.versions[0].all_nodes().into() + } else { + let set = self + .versions + .iter() + .map(|x| x.all_nodes()) + .flatten() + .collect::<HashSet<_>>(); + set.into_iter().copied().collect::<Vec<_>>().into() + } + } + pub fn all_nongateway_nodes(&self) -> Cow<'_, [Uuid]> { // TODO: cache this if self.versions.len() == 1 { |