You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
924 B
Rust
35 lines
924 B
Rust
use std::env;
|
|
use rocket_dyn_templates::{Template, context};
|
|
|
|
use crate::data::node::GetInfoResponse;
|
|
use crate::data::transaction::{GetTransactionPool, Transaction};
|
|
use crate::helpers::build_rpc;
|
|
|
|
#[get("/")]
|
|
pub async fn home() -> Template {
|
|
let daemon = env::var("DAEMON_URI").unwrap();
|
|
let daemon_info: GetInfoResponse = build_rpc(&"get_info", None, true)
|
|
.await.send()
|
|
.await.unwrap().json()
|
|
.await.unwrap();
|
|
|
|
let tx_pool: GetTransactionPool = build_rpc(&"get_transaction_pool", None, true)
|
|
.await.send()
|
|
.await.unwrap().json()
|
|
.await.unwrap();
|
|
|
|
let mut pool_txs: Vec<Transaction> = tx_pool.transactions.unwrap_or(vec![]);
|
|
|
|
for f in &mut pool_txs {
|
|
f.process();
|
|
};
|
|
|
|
let context = context!{
|
|
daemon_info: daemon_info,
|
|
tx_pool_txs: pool_txs,
|
|
daemon_uri: daemon
|
|
};
|
|
|
|
Template::render("home", context)
|
|
|
|
} |