more debugging

This commit is contained in:
Christien Rioux 2024-03-04 12:24:14 -05:00
parent 7e5d0d1204
commit 4b632d8156
4 changed files with 40 additions and 5 deletions

View File

@ -69,12 +69,13 @@ impl RPCProcessor {
); );
let debug_string_stmt = format!( let debug_string_stmt = format!(
"IN <== ValueChanged({} #{:?}+{}{}) <= {}", "IN <== ValueChanged({} #{:?}+{}{}) from {} <= {}",
key, key,
subkeys, subkeys,
count, count,
debug_string_value, debug_string_value,
msg.header.direct_sender_node_id() inbound_node_id,
msg.header.direct_sender_node_id(),
); );
log_rpc!(debug "{}", debug_string_stmt); log_rpc!(debug "{}", debug_string_stmt);

View File

@ -15,6 +15,18 @@ impl StorageManager {
}; };
remote_record_store.debug_records() remote_record_store.debug_records()
} }
pub(crate) async fn debug_opened_records(&self) -> String {
let inner = self.inner.lock().await;
format!(
"{:#?}",
inner
.opened_records
.keys()
.copied()
.collect::<Vec<TypedKey>>()
)
}
pub(crate) async fn purge_local_records(&self, reclaim: Option<usize>) -> String { pub(crate) async fn purge_local_records(&self, reclaim: Option<usize>) -> String {
let mut inner = self.inner.lock().await; let mut inner = self.inner.lock().await;
let Some(local_record_store) = &mut inner.local_record_store else { let Some(local_record_store) = &mut inner.local_record_store else {
@ -66,8 +78,17 @@ impl StorageManager {
let Some(local_record_store) = &inner.local_record_store else { let Some(local_record_store) = &inner.local_record_store else {
return "not initialized".to_owned(); return "not initialized".to_owned();
}; };
local_record_store.debug_record_info(key) let local_debug = local_record_store.debug_record_info(key);
let opened_debug = if let Some(o) = inner.opened_records.get(&key) {
format!("Opened Record: {:#?}\n", o)
} else {
"".to_owned()
};
format!("{}\n{}", local_debug, opened_debug)
} }
pub(crate) async fn debug_remote_record_info(&self, key: TypedKey) -> String { pub(crate) async fn debug_remote_record_info(&self, key: TypedKey) -> String {
let inner = self.inner.lock().await; let inner = self.inner.lock().await;
let Some(remote_record_store) = &inner.remote_record_store else { let Some(remote_record_store) = &inner.remote_record_store else {

View File

@ -1053,8 +1053,16 @@ where
} }
pub fn debug_record_info(&self, key: TypedKey) -> String { pub fn debug_record_info(&self, key: TypedKey) -> String {
self.peek_record(key, |r| format!("{:#?}", r)) let record_info = self
.unwrap_or("Not found".to_owned()) .peek_record(key, |r| format!("{:#?}", r))
.unwrap_or("Not found".to_owned());
let watched_record = match self.watched_records.get(&RecordTableKey { key }) {
Some(w) => {
format!("Remote Watches: {:#?}", w)
}
None => "No remote watches".to_owned(),
};
format!("{}\n{}\n", record_info, watched_record)
} }
pub async fn debug_record_subkey_info(&self, key: TypedKey, subkey: ValueSubkey) -> String { pub async fn debug_record_subkey_info(&self, key: TypedKey, subkey: ValueSubkey) -> String {

View File

@ -1388,6 +1388,11 @@ impl VeilidAPI {
out += &storage_manager.debug_remote_records().await; out += &storage_manager.debug_remote_records().await;
out out
} }
"opened" => {
let mut out = "Opened Records:\n".to_string();
out += &storage_manager.debug_opened_records().await;
out
}
_ => "Invalid scope\n".to_owned(), _ => "Invalid scope\n".to_owned(),
}; };
Ok(out) Ok(out)