aboutsummaryrefslogtreecommitdiff
path: root/src/model/k2v/seen.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-01-10 12:54:24 +0100
committerAlex Auvolat <alex@adnab.me>2023-01-10 12:54:24 +0100
commit43fd6c1526339fb444e5e25021f42d0aee252b27 (patch)
tree29b4f40544ee58b635aafdca5246f955d255466c /src/model/k2v/seen.rs
parent789540ca379efd710f1e2699fd458b4821f36a5b (diff)
downloadgarage-43fd6c1526339fb444e5e25021f42d0aee252b27.tar.gz
garage-43fd6c1526339fb444e5e25021f42d0aee252b27.zip
PollRange RPC
Diffstat (limited to 'src/model/k2v/seen.rs')
-rw-r--r--src/model/k2v/seen.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/model/k2v/seen.rs b/src/model/k2v/seen.rs
index b8f4ff27..d2cd54c7 100644
--- a/src/model/k2v/seen.rs
+++ b/src/model/k2v/seen.rs
@@ -17,6 +17,7 @@ use garage_util::error::{Error, OkOrMessage};
use crate::k2v::causality::*;
use crate::k2v::item_table::*;
+use crate::k2v::sub::*;
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct RangeSeenMarker {
@@ -29,6 +30,18 @@ impl RangeSeenMarker {
Self::default()
}
+ pub fn restrict(&mut self, range: &PollRange) {
+ if let Some(start) = &range.start {
+ self.items = self.items.split_off(start);
+ }
+ if let Some(end) = &range.end {
+ self.items.split_off(end);
+ }
+ if let Some(pfx) = &range.prefix {
+ self.items.retain(|k, _v| k.starts_with(pfx));
+ }
+ }
+
pub fn mark_seen_node_items<'a, I: IntoIterator<Item = &'a K2VItem>>(
&mut self,
node: Uuid,