mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-10-01 01:26:08 -04:00
Merge branch 'watch-work' into 'main'
Fix set_dht_value and watch_value See merge request veilid/veilid!268
This commit is contained in:
commit
fa4d779ec5
@ -1037,7 +1037,7 @@ where
|
|||||||
let Some(member_check) = self.with_record(key, |record| {
|
let Some(member_check) = self.with_record(key, |record| {
|
||||||
let schema = record.schema();
|
let schema = record.schema();
|
||||||
let owner = *record.owner();
|
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 {
|
}) else {
|
||||||
// Record not found
|
// Record not found
|
||||||
return Ok(WatchResult::Rejected);
|
return Ok(WatchResult::Rejected);
|
||||||
|
@ -100,11 +100,17 @@ impl StorageManager {
|
|||||||
return Ok(NetworkResult::invalid_message("Schema validation failed"));
|
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
|
// We have a prior value, ensure this is a newer sequence number
|
||||||
let prior_seq = ctx.value.value_data().seq();
|
let prior_seq = ctx.value.value_data().seq();
|
||||||
let new_seq = value.value_data().seq();
|
let new_seq = value.value_data().seq();
|
||||||
if new_seq > prior_seq {
|
if new_seq >= prior_seq {
|
||||||
// If the sequence number is greater, keep it
|
// If the sequence number is greater or equal, keep it
|
||||||
ctx.value = Arc::new(value);
|
ctx.value = Arc::new(value);
|
||||||
// One node has shown us this value so far
|
// One node has shown us this value so far
|
||||||
ctx.value_nodes = vec![next_node];
|
ctx.value_nodes = vec![next_node];
|
||||||
|
Loading…
Reference in New Issue
Block a user