Skip to content

Commit

Permalink
Run fetch param script
Browse files Browse the repository at this point in the history
  • Loading branch information
Duddino committed Oct 6, 2024
1 parent 63ab3c8 commit a7ea49b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src-tauri/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ pub enum PIVXErrors {

#[error("Invalid response from RPC")]
InvalidResponse,

#[error("Failed to fetch sapling params")]
FetchParamsFailed,
}

pub type Result<T> = std::result::Result<T, PIVXErrors>;
5 changes: 4 additions & 1 deletion src-tauri/src/explorer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ async fn get_explorer() -> &'static DefaultExplorer {
let pivx_rpc = PIVXRpc::new(&format!("http://127.0.0.1:{}", RPC_PORT))
.await
.unwrap();
// FIXME: refactor this to accept HOME
let address_index = AddressIndex::new(
SqlLite::new(PathBuf::from("~/test.sqlite")).await.unwrap(),
SqlLite::new(PathBuf::from("/home/duddino/test.sqlite"))
.await
.unwrap(),
pivx_rpc.clone(),
);
std::mem::forget(pivx);
Expand Down
14 changes: 12 additions & 2 deletions src-tauri/src/pivx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::error::PIVXErrors;
use flate2::read::GzDecoder;
use std::fs::File;
use std::path::{Path, PathBuf};
use std::process::Command;
use tar::Archive;

use crate::binary::BinaryDefinition;
Expand All @@ -15,8 +16,17 @@ impl BinaryDefinition for PIVXDefinition {
fn decompress_archive(&self, dir: &Path) -> Result<(), PIVXErrors> {
let mut tarball = Archive::new(GzDecoder::new(File::open(dir.join("pivxd.tar.gz"))?));
tarball.unpack(dir)?;

Ok(())
let pivx_dir = dir.join("pivx-5.6.1");
let script_path = pivx_dir.join("install-params.sh");
let mut handle = Command::new(script_path)
.current_dir(pivx_dir)
.spawn()
.map_err(|_| PIVXErrors::FetchParamsFailed)?;
let status = handle.wait().map_err(|_| PIVXErrors::FetchParamsFailed)?;
match status.success() {
true => Ok(()),
false => Err(PIVXErrors::FetchParamsFailed),
}
}

fn get_url(&self) -> &str {
Expand Down

0 comments on commit a7ea49b

Please sign in to comment.