Added a workaround for old domains, that have old name encryption.

This commit is contained in:
Revertron committed 2021-04-17 13:15:53 +02:00
1 parent 67757a3f16
commit 64b353f069
2 files changed
+6 -6

No files matched your search

+4 -4
View File
@@ -414,7 +414,7 @@ impl Chain {
Ok(mut statement) => { Ok(mut statement) => {
while statement.next().unwrap() == State::Row { while statement.next().unwrap() == State::Row {
let data = statement.read::<String>(0).unwrap(); let data = statement.read::<String>(0).unwrap();
debug!("Got zone data {}", &data); //debug!("Got zone data {}", &data);
if let Ok(zone_data) = serde_json::from_str::<ZoneData>(&data) { if let Ok(zone_data) = serde_json::from_str::<ZoneData>(&data) {
map.insert(zone_data.name.clone(), zone_data); map.insert(zone_data.name.clone(), zone_data);
} }
@@ -522,7 +522,7 @@ impl Chain {
} }
} }
pub fn get_my_domains(&self, keystore: &Option<Keystore>) -> HashMap<String, (i64, DomainData)> { pub fn get_my_domains(&self, keystore: &Option<Keystore>) -> HashMap<Bytes, (String, i64, DomainData)> {
if keystore.is_none() { if keystore.is_none() {
return HashMap::new(); return HashMap::new();
} }
@@ -540,7 +540,7 @@ impl Chain {
let class = String::from("domain"); let class = String::from("domain");
let data = statement.read::<String>(4).unwrap(); let data = statement.read::<String>(4).unwrap();
let pub_key = Bytes::from_bytes(&statement.read::<Vec<u8>>(5).unwrap()); let pub_key = Bytes::from_bytes(&statement.read::<Vec<u8>>(5).unwrap());
let transaction = Transaction { identity, confirmation, class, data, pub_key }; let transaction = Transaction { identity: identity.clone(), confirmation, class, data, pub_key };
//debug!("Found transaction for domain {}: {:?}", domain, &transaction); //debug!("Found transaction for domain {}: {:?}", domain, &transaction);
if let Some(data) = transaction.get_domain_data() { if let Some(data) = transaction.get_domain_data() {
let b = self.get_block(index - 1).unwrap(); let b = self.get_block(index - 1).unwrap();
@@ -550,7 +550,7 @@ impl Chain {
domain = String::from("unknown"); domain = String::from("unknown");
} }
trace!("Found my domain {}", domain); trace!("Found my domain {}", domain);
result.insert(domain, (timestamp, data)); result.insert(identity, (domain, timestamp, data));
} }
} }
result result
+2 -2
View File
@@ -327,8 +327,8 @@ fn load_domains(context: &mut MutexGuard<Context>, handle: &Handle<()>) {
web_view.eval("clearMyDomains();") web_view.eval("clearMyDomains();")
}); });
let domains = context.chain.get_my_domains(&context.keystore); let domains = context.chain.get_my_domains(&context.keystore);
debug!("Domains: {:?}", &domains); debug!("Domains: {:?}", &domains.values());
for (domain, (timestamp, data)) in domains { for (_identity, (domain, timestamp, data)) in domains {
let d = serde_json::to_string(&data).unwrap(); let d = serde_json::to_string(&data).unwrap();
let command = format!("addMyDomain('{}', {}, '{}');", &domain, timestamp, &d); let command = format!("addMyDomain('{}', {}, '{}');", &domain, timestamp, &d);
let _ = handle.dispatch(move |web_view|{ let _ = handle.dispatch(move |web_view|{