Merge branch 'watch-work' into 'main'

Fix set_dht_value and watch_value

See merge request veilid/veilid!268
This commit is contained in:
Christien Rioux 2024-04-07 03:03:48 +00:00
commit fa4d779ec5
2 changed files with 9 additions and 3 deletions

View File

@ -1037,7 +1037,7 @@ where
let Some(member_check) = self.with_record(key, |record| {
let schema = record.schema();
let owner = *record.owner();
Box::new(move |watcher| owner == params.watcher || schema.is_member(&watcher))
Box::new(move |watcher| owner == watcher || schema.is_member(&watcher))
}) else {
// Record not found
return Ok(WatchResult::Rejected);

View File

@ -100,11 +100,17 @@ impl StorageManager {
return Ok(NetworkResult::invalid_message("Schema validation failed"));
}
// If we got a value back it should be different than the one we are setting
if ctx.value.value_data() == value.value_data() {
// Move to the next node
return Ok(NetworkResult::invalid_message("same value returned"));
}
// We have a prior value, ensure this is a newer sequence number
let prior_seq = ctx.value.value_data().seq();
let new_seq = value.value_data().seq();
if new_seq > prior_seq {
// If the sequence number is greater, keep it
if new_seq >= prior_seq {
// If the sequence number is greater or equal, keep it
ctx.value = Arc::new(value);
// One node has shown us this value so far
ctx.value_nodes = vec![next_node];