mirror of
https://github.com/transatoshi-mw/grin-explorer.git
synced 2025-10-22 05:43:42 +00:00
remove search by outputs feature
This commit is contained in:
45
src/main.rs
45
src/main.rs
@@ -19,7 +19,6 @@ use crate::data::Dashboard;
|
||||
use crate::data::Block;
|
||||
use crate::data::Transactions;
|
||||
use crate::data::Kernel;
|
||||
use crate::data::Output;
|
||||
use crate::requests::CONFIG;
|
||||
|
||||
|
||||
@@ -150,33 +149,11 @@ async fn kernel(excess: &str) -> Template {
|
||||
}
|
||||
|
||||
|
||||
// Rendering page for a specified output.
|
||||
#[get("/output/<commit>")]
|
||||
async fn output(commit: &str) -> Template {
|
||||
let mut output = Output::new();
|
||||
|
||||
let _ = requests::get_output(&commit, &mut output).await;
|
||||
|
||||
if output.commit.is_empty() == false {
|
||||
return Template::render("output", context! {
|
||||
route: "output",
|
||||
cg_api: CONFIG.coingecko_api.clone(),
|
||||
output,
|
||||
})
|
||||
}
|
||||
|
||||
return Template::render("error", context! {
|
||||
route: "error",
|
||||
cg_api: CONFIG.coingecko_api.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// Handling search request.
|
||||
// Using Option<&str> to match '/search' query without input params.
|
||||
// https://github.com/rwf2/Rocket/issues/608
|
||||
#[get("/search?<input>")]
|
||||
pub async fn search(input: Option<&str>) -> Either<Template, Redirect> {
|
||||
fn search(input: Option<&str>) -> Either<Template, Redirect> {
|
||||
// Unwrap Option and forward to Search page if no parameters
|
||||
let input = match input {
|
||||
Some(value) => value,
|
||||
@@ -197,23 +174,9 @@ pub async fn search(input: Option<&str>) -> Either<Template, Redirect> {
|
||||
} else if input.len() == 64 {
|
||||
return Either::Right(Redirect::to(uri!(block_header_by_hash(input))));
|
||||
|
||||
// Kernel or Output
|
||||
// Kernel
|
||||
} else if input.len() == 66 {
|
||||
// First search for Kernel
|
||||
let mut kernel = Kernel::new();
|
||||
|
||||
let _ = requests::get_kernel(&input, &mut kernel).await;
|
||||
|
||||
if kernel.excess.is_empty() == false {
|
||||
return Either::Left(Template::render("kernel", context! {
|
||||
route: "kernel",
|
||||
cg_api: CONFIG.coingecko_api.clone(),
|
||||
kernel,
|
||||
}));
|
||||
} else {
|
||||
// If Kernel not found, then search for Output
|
||||
return Either::Right(Redirect::to(uri!(output(input))));
|
||||
}
|
||||
return Either::Right(Redirect::to(uri!(kernel(input))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,7 +646,7 @@ async fn main() {
|
||||
block_weight, block_details_by_height, block_header_by_hash,
|
||||
soft_supply, production_cost, reward_ratio, breakeven_cost,
|
||||
last_block_age, block_list_by_height, block_list_index, search, kernel,
|
||||
output, api_owner, api_foreign])
|
||||
api_owner, api_foreign])
|
||||
.mount("/static", FileServer::from("static"))
|
||||
.attach(Template::fairing())
|
||||
.launch()
|
||||
|
Reference in New Issue
Block a user