ported zcashlc_rewind_to_height

This commit is contained in:
Francisco Gindre 2020-11-25 10:20:45 -03:00
parent bf444f7179
commit 8a7fda77d6
1 changed files with 11 additions and 11 deletions

View File

@ -665,18 +665,18 @@ pub extern "C" fn zcashlc_rewind_to_height(
height: i32, height: i32,
) -> i32 { ) -> i32 {
let res = catch_panic(|| { let res = catch_panic(|| {
let db_data = Path::new(OsStr::from_bytes(unsafe { let db_data = wallet_db(db_data, db_data_len)?;
slice::from_raw_parts(db_data, db_data_len)
}));
match rewind_to_height(&db_data, height) { let mut update_ops = (&db_data)
Ok(()) => Ok(1), .get_update_ops()
Err(e) => Err(format_err!( .map_err(|e| format_err!("Could not obtain a writable database connection: {}", e))?;
"Error while rewinding data DB to height {}: {}",
height, let height = BlockHeight::try_from(height)?;
e (&mut update_ops)
)), .transactionally(|ops| ops.rewind_to_height(&NETWORK, height))
} .map(|_| 1)
.map_err(|e| format_err!("Error while rewinding data DB to height {}: {}", height, e))
}); });
unwrap_exc_or_null(res) unwrap_exc_or_null(res)
} }