[wasm] Fix SystemTime for wasm and refactor the cli part

This commit is contained in:
Alekos Filini
2020-05-08 23:30:45 +02:00
parent e5ff696e73
commit 1ff9852cff
5 changed files with 325 additions and 291 deletions

View File

@@ -498,6 +498,7 @@ where
// Internals
#[cfg(not(target_arch = "wasm32"))]
fn get_timestamp() -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
@@ -505,6 +506,11 @@ where
.as_secs()
}
#[cfg(target_arch = "wasm32")]
fn get_timestamp() -> u64 {
0
}
fn get_descriptor_for(&self, script_type: ScriptType) -> &ExtendedDescriptor {
let desc = match script_type {
ScriptType::External => &self.descriptor,
@@ -646,6 +652,7 @@ where
// safe to run only on the descriptor because we assume the change descriptor also has
// the same structure
let desc = self.descriptor.derive_from_psbt_input(psbt, n);
debug!("{:?}", psbt.inputs[n].hd_keypaths);
debug!("reconstructed descriptor is {:?}", desc);
let desc = match desc {
@@ -765,6 +772,7 @@ where
// cache a few of our addresses
if last_addr.is_none() {
let mut address_batch = self.database.borrow().begin_batch();
#[cfg(not(target_arch = "wasm32"))]
let start = Instant::now();
for i in 0..=max_address {
@@ -790,6 +798,7 @@ where
}
}
#[cfg(not(target_arch = "wasm32"))]
info!(
"derivation of {} addresses, took {} ms",
max_address,