fix: android build & CONFIG deadlock

This commit is contained in:
csf
2022-07-28 22:06:59 +08:00
parent 6bbfe13028
commit da2906c95f
7 changed files with 36 additions and 18 deletions

View File

@@ -584,6 +584,17 @@ impl Config {
config.store();
}
pub fn get_sk_uuid() -> Vec<u8> {
// for uuid, avoid deadlock
let mut config = Config::load_::<Config>("");
if config.key_pair.0.is_empty() {
let (pk, sk) = sign::gen_keypair();
config.key_pair = (sk.0.to_vec(), pk.0.into());
Config::store_(&config, "");
}
config.key_pair.1
}
pub fn get_key_pair() -> (Vec<u8>, Vec<u8>) {
// lock here to make sure no gen_keypair more than once
let mut config = CONFIG.write().unwrap();