From eb08b348b1c7027e30f211640de635602c48042b Mon Sep 17 00:00:00 2001 From: Arthur Roberts Date: Sun, 14 Jul 2024 19:21:41 +0100 Subject: [PATCH] Added updating blockchains button --- src/main.rs | 11 +++++++++-- templates/index.html.tera | 4 +--- templates/update_complete.html.tera | 7 +++++++ 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 templates/update_complete.html.tera diff --git a/src/main.rs b/src/main.rs index 4ff00c1..c282413 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ #[macro_use] extern crate rocket; use rocket_dyn_templates::{context, Template}; -use blockchain_time::{BlockchainInfo, BlockchainSupported}; +use blockchain_time::{BlockchainInfo, BlockchainSupported, update_all_blockheights}; #[get("/")] fn index() -> Template { @@ -16,8 +16,15 @@ fn index() -> Template { Template::render("index", context) } +#[get("/update_blockchains")] +fn update_blockchains() -> Template { + update_all_blockheights(); + Template::render("update_complete", context!{}) +} + #[launch] fn rocket() -> _ { - rocket::build().mount("/", routes![index]) + rocket::build().mount("/", routes![index, update_blockchains]) +// .mount("/update_blockchains", routes![update_blockchains]) .attach(Template::fairing()) } diff --git a/templates/index.html.tera b/templates/index.html.tera index 265c673..a6236a7 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -41,9 +41,7 @@ {% endfor %} -
- -
+ Update Blockchain Information

Pressing the above button might take some time... or it might crash the appliaction... or it'll do what you want... you won't know till you press it.

diff --git a/templates/update_complete.html.tera b/templates/update_complete.html.tera new file mode 100644 index 0000000..cb8e650 --- /dev/null +++ b/templates/update_complete.html.tera @@ -0,0 +1,7 @@ + + + + + If you're seeing this, it probably worked. Go back here to check. + +