mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-12-26 15:59:24 -05:00
fix set dht value during a sequence number conflict
This commit is contained in:
parent
6f49acffbb
commit
149aa49575
@ -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