mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-12-25 23:39:22 -05:00
ensure get_value doesn't try to pull values unless they are close enough
This commit is contained in:
parent
a211c7cce3
commit
4a76353f33
@ -230,16 +230,29 @@ impl RPCProcessor {
|
|||||||
log_rpc!(debug "{}", debug_string);
|
log_rpc!(debug "{}", debug_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if we have this record ourselves
|
// See if we would have accepted this as a set
|
||||||
let storage_manager = self.storage_manager();
|
let set_value_count = {
|
||||||
let subkey_result = network_result_try!(storage_manager
|
let c = self.config.get();
|
||||||
.inbound_get_value(key, subkey, want_descriptor)
|
c.network.dht.set_value_count as usize
|
||||||
.await
|
};
|
||||||
.map_err(RPCError::internal)?);
|
let (subkey_result_value, subkey_result_descriptor) = if closer_to_key_peers.len() >= set_value_count {
|
||||||
|
// Not close enough
|
||||||
|
(None, None)
|
||||||
|
} else {
|
||||||
|
// Close enough, lets get it
|
||||||
|
|
||||||
|
// See if we have this record ourselves
|
||||||
|
let storage_manager = self.storage_manager();
|
||||||
|
let subkey_result = network_result_try!(storage_manager
|
||||||
|
.inbound_get_value(key, subkey, want_descriptor)
|
||||||
|
.await
|
||||||
|
.map_err(RPCError::internal)?);
|
||||||
|
(subkey_result.value, subkey_result.descriptor)
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(feature="debug-dht")]
|
#[cfg(feature="debug-dht")]
|
||||||
{
|
{
|
||||||
let debug_string_value = subkey_result.value.as_ref().map(|v| {
|
let debug_string_value = subkey_result_value.as_ref().map(|v| {
|
||||||
format!(" len={} seq={} writer={}",
|
format!(" len={} seq={} writer={}",
|
||||||
v.value_data().data().len(),
|
v.value_data().data().len(),
|
||||||
v.value_data().seq(),
|
v.value_data().seq(),
|
||||||
@ -252,7 +265,7 @@ impl RPCProcessor {
|
|||||||
key,
|
key,
|
||||||
subkey,
|
subkey,
|
||||||
debug_string_value,
|
debug_string_value,
|
||||||
if subkey_result.descriptor.is_some() {
|
if subkey_result_descriptor.is_some() {
|
||||||
" +desc"
|
" +desc"
|
||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
@ -266,9 +279,9 @@ impl RPCProcessor {
|
|||||||
|
|
||||||
// Make GetValue answer
|
// Make GetValue answer
|
||||||
let get_value_a = RPCOperationGetValueA::new(
|
let get_value_a = RPCOperationGetValueA::new(
|
||||||
subkey_result.value,
|
subkey_result_value,
|
||||||
closer_to_key_peers,
|
closer_to_key_peers,
|
||||||
subkey_result.descriptor,
|
subkey_result_descriptor,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Send GetValue answer
|
// Send GetValue answer
|
||||||
|
Loading…
Reference in New Issue
Block a user