Added current block info and skeleton of website
This commit is contained in:
@@ -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>,
|
||||
}
|
||||
|
||||
|
||||
11
src/main.rs
11
src/main.rs
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user