Debug breadcrumbs

This commit is contained in:
2026-05-06 22:43:31 +02:00
parent 6154731576
commit f9f3d77474
+14
View File
@@ -1103,23 +1103,37 @@ impl Config {
pub fn get_key_pair() -> KeyPair {
// lock here to make sure no gen_keypair more than once
// no use of CONFIG directly here to ensure no recursive calling in Config::load because of password dec which calling this function
log::info!("breadcrumb: get_key_pair before KEY_PAIR.lock");
let mut lock = KEY_PAIR.lock().unwrap();
log::info!("breadcrumb: get_key_pair after KEY_PAIR.lock");
if let Some(p) = lock.as_ref() {
log::info!("breadcrumb: get_key_pair cache hit");
return p.clone();
}
log::info!("breadcrumb: get_key_pair before Config::load_");
let mut config = Config::load_::<Config>("");
log::info!("breadcrumb: get_key_pair after Config::load_, key_pair_empty={}", config.key_pair.0.is_empty());
if config.key_pair.0.is_empty() {
log::info!("Generated new keypair for id: {}", config.id);
log::info!("breadcrumb: get_key_pair before sign::gen_keypair");
let (pk, sk) = sign::gen_keypair();
log::info!("breadcrumb: get_key_pair after sign::gen_keypair");
let key_pair = (sk.0.to_vec(), pk.0.into());
config.key_pair = key_pair.clone();
log::info!("breadcrumb: get_key_pair before thread::spawn for store");
std::thread::spawn(|| {
log::info!("breadcrumb: get_key_pair store-thread before CONFIG.write");
let mut config = CONFIG.write().unwrap();
log::info!("breadcrumb: get_key_pair store-thread after CONFIG.write");
config.key_pair = key_pair;
log::info!("breadcrumb: get_key_pair store-thread before config.store");
config.store();
log::info!("breadcrumb: get_key_pair store-thread after config.store");
});
log::info!("breadcrumb: get_key_pair after thread::spawn");
}
*lock = Some(config.key_pair.clone());
log::info!("breadcrumb: get_key_pair returning");
config.key_pair
}