fix expiration

This commit is contained in:
John Smith 2023-12-10 14:25:04 -05:00 committed by Christien Rioux
parent d269b25a23
commit b6f1e706f7
2 changed files with 8 additions and 2 deletions

View File

@ -207,6 +207,10 @@ impl RPCProcessor {
}; };
let ret_expiration = if closer_to_key_peers.len() >= set_value_count { let ret_expiration = if closer_to_key_peers.len() >= set_value_count {
// Not close enough // Not close enough
#[cfg(feature = "debug-dht")]
log_rpc!(debug "Not close enough for watch value");
Timestamp::default() Timestamp::default()
} else { } else {
// Close enough, lets watch it // Close enough, lets watch it

View File

@ -746,7 +746,7 @@ where
&mut self, &mut self,
key: TypedKey, key: TypedKey,
subkeys: ValueSubkeyRangeSet, subkeys: ValueSubkeyRangeSet,
expiration: Timestamp, mut expiration: Timestamp,
count: u32, count: u32,
target: Target, target: Target,
watcher: CryptoKey, watcher: CryptoKey,
@ -760,7 +760,9 @@ where
let cur_ts = get_timestamp(); let cur_ts = get_timestamp();
let max_ts = cur_ts + self.limits.max_watch_expiration.as_u64(); let max_ts = cur_ts + self.limits.max_watch_expiration.as_u64();
let min_ts = cur_ts + self.limits.min_watch_expiration.as_u64(); let min_ts = cur_ts + self.limits.min_watch_expiration.as_u64();
if expiration.as_u64() < min_ts || expiration.as_u64() > max_ts { if expiration.as_u64() == 0 {
expiration = Timestamp::new(max_ts);
} else if expiration.as_u64() < min_ts || expiration.as_u64() > max_ts {
return Ok(None); return Ok(None);
} }