Added current block info and skeleton of website

This commit is contained in:
2024-07-14 19:08:38 +01:00
parent 0fbd04e791
commit cc7678ec18
5 changed files with 147 additions and 18 deletions

View File

@@ -1,7 +1,9 @@
use chrono::prelude::*;
use lazy_static::lazy_static;
use rocket::serde::Serialize;
use std::convert::Into;
use std::sync::RwLock;
use serde_with::{serde_as, DisplayFromStr};
pub enum BlockchainSupported {
BTC,
@@ -12,10 +14,12 @@ pub enum BlockchainSupported {
type BlockHeight = i64;
#[derive(Clone, Copy, PartialEq, Debug)]
#[serde_as]
#[derive(Clone, Copy, PartialEq, Debug, Serialize)]
pub struct BlockchainInfo {
block_period: u64, // In seconds
latest_block_height: BlockHeight,
#[serde_as(as = "DisplayFromStr")]
latest_block_time: DateTime<Utc>,
}

View File

@@ -1,9 +1,18 @@
#[macro_use] extern crate rocket;
use rocket_dyn_templates::{context, Template};
use blockchain_time::{BlockchainInfo, BlockchainSupported};
#[get("/")]
fn index() -> Template {
let context = context! {};
let blockchain_infos: Vec<(String, BlockchainInfo)> = vec!{
("BSV".to_string(), BlockchainSupported::BSV.into()),
("BTC".to_string(), BlockchainSupported::BTC.into()),
("XMR".to_string(), BlockchainSupported::XMR.into()),
("ETH".to_string(), BlockchainSupported::ETH.into()),
};
let context = context! {
blockchain_infos
};
Template::render("index", context)
}