fix offline subkey write reporting to eliminate spurious notifications

add more detail to public address check
This commit is contained in:
Christien Rioux 2024-06-26 17:03:06 +00:00
parent 6f37e09008
commit f32219c45c
3 changed files with 34 additions and 28 deletions

View File

@ -268,6 +268,11 @@ impl NetworkManager {
if detect_address_changes { if detect_address_changes {
// Reset the address check cache now so we can start detecting fresh // Reset the address check cache now so we can start detecting fresh
info!("Public address has changed, detecting public dial info"); info!("Public address has changed, detecting public dial info");
log_net!(debug "report_global_socket_address\nsocket_address: {:#?}\nflow: {:#?}\nreporting_peer: {:#?}", socket_address, flow, reporting_peer);
log_net!(debug
"public_address_check_cache: {:#?}",
inner.public_address_check_cache
);
inner.public_address_check_cache.clear(); inner.public_address_check_cache.clear();

View File

@ -139,14 +139,19 @@ impl StorageManager {
pub async fn terminate(&self) { pub async fn terminate(&self) {
log_stor!(debug "starting storage manager shutdown"); log_stor!(debug "starting storage manager shutdown");
let mut inner = self.inner.lock().await; {
inner.terminate().await; let mut inner = self.inner.lock().await;
inner.terminate().await;
}
// Cancel all tasks // Cancel all tasks
self.cancel_tasks().await; self.cancel_tasks().await;
// Release the storage manager // Release the storage manager
*inner = Self::new_inner(self.unlocked_inner.clone()); {
let mut inner = self.inner.lock().await;
*inner = Self::new_inner(self.unlocked_inner.clone());
}
log_stor!(debug "finished storage manager shutdown"); log_stor!(debug "finished storage manager shutdown");
} }

View File

@ -10,18 +10,13 @@ impl StorageManager {
_last_ts: Timestamp, _last_ts: Timestamp,
_cur_ts: Timestamp, _cur_ts: Timestamp,
) -> EyreResult<()> { ) -> EyreResult<()> {
let (mut offline_subkey_writes, opt_update_callback) = { let mut offline_subkey_writes = {
let mut inner = self.lock().await?; let mut inner = self.lock().await?;
let out = ( let out = inner.offline_subkey_writes.clone();
inner.offline_subkey_writes.clone(),
inner.update_callback.clone(),
);
inner.offline_subkey_writes.clear(); inner.offline_subkey_writes.clear();
out out
}; };
let mut fanout_results = vec![];
for (key, osw) in offline_subkey_writes.iter_mut() { for (key, osw) in offline_subkey_writes.iter_mut() {
if poll!(stop_token.clone()).is_ready() { if poll!(stop_token.clone()).is_ready() {
log_stor!(debug "Offline subkey writes cancelled."); log_stor!(debug "Offline subkey writes cancelled.");
@ -32,6 +27,8 @@ impl StorageManager {
break; break;
}; };
let mut fanout_results = vec![];
let mut written_subkeys = ValueSubkeyRangeSet::new(); let mut written_subkeys = ValueSubkeyRangeSet::new();
for subkey in osw.subkeys.iter() { for subkey in osw.subkeys.iter() {
let get_result = { let get_result = {
@ -63,7 +60,7 @@ impl StorageManager {
*key, *key,
subkey, subkey,
osw.safety_selection, osw.safety_selection,
value, value.clone(),
descriptor, descriptor,
) )
.await; .await;
@ -85,24 +82,23 @@ impl StorageManager {
&result.fanout_result, &result.fanout_result,
); );
if !was_offline { if !was_offline {
if let Some(update_callback) = opt_update_callback.clone() {
// Send valuechange with dead count and no subkeys
update_callback(VeilidUpdate::ValueChange(Box::new(
VeilidValueChange {
key: *key,
subkeys: ValueSubkeyRangeSet::single(subkey),
count: u32::MAX,
value: Some(
result
.signed_value_data
.value_data()
.clone(),
),
},
)));
}
written_subkeys.insert(subkey); written_subkeys.insert(subkey);
}; }
// Set the new value if it differs from what was asked to set
if result.signed_value_data.value_data() != value.value_data() {
// Record the newer value and send and update since it is different than what we just set
let mut inner = self.lock().await?;
inner
.handle_set_local_value(
*key,
subkey,
result.signed_value_data.clone(),
WatchUpdateMode::UpdateAll,
)
.await?;
}
fanout_results.push((subkey, result.fanout_result)); fanout_results.push((subkey, result.fanout_result));
break; break;
} }