Initial commit

This commit is contained in:
aglkm
2024-05-03 14:23:37 +03:00
commit a5ca343c52
25 changed files with 26114 additions and 0 deletions

157
src/data.rs Normal file
View File

@@ -0,0 +1,157 @@
use serde::{Serialize, Deserialize};
// Dashboard data
#[derive(Debug)]
pub struct Dashboard {
// status
pub height: String,
pub sync: String,
pub node_ver: String,
pub proto_ver: String,
// connections
pub inbound: u16,
pub outbound: u16,
//price & market
pub supply: String,
pub soft_supply: String,
pub inflation: String,
pub price_usd: String,
pub price_btc: String,
pub volume_usd: String,
pub volume_btc: String,
pub cap_usd: String,
pub cap_btc: String,
// blockchain
pub disk_usage: String,
pub age: String,
// hashrate
pub hashrate: String,
pub difficulty: String,
// mining
pub production_cost: String,
pub reward_ratio: String,
// mempool
pub txns: String,
pub stem: String,
}
impl Dashboard {
pub fn new() -> Dashboard {
Dashboard {
height: String::new(),
sync: String::new(),
node_ver: String::new(),
proto_ver: String::new(),
inbound: 0,
outbound: 0,
supply: String::new(),
soft_supply: String::new(),
inflation: String::new(),
price_usd: String::new(),
price_btc: String::new(),
volume_usd: String::new(),
volume_btc: String::new(),
cap_usd: String::new(),
cap_btc: String::new(),
disk_usage: String::new(),
age: String::new(),
hashrate: String::new(),
difficulty: String::new(),
production_cost: String::new(),
reward_ratio: String::new(),
txns: String::new(),
stem: String::new(),
}
}
}
// Block data
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Block {
pub hash: String,
pub height: String,
pub time: String,
pub version: String,
pub weight: f64,
pub fees: f64,
pub kernels: Vec<(String, String, String)>,
pub inputs: Vec<String>,
pub outputs: Vec<(String,String)>,
pub ker_len: u64,
pub in_len: u64,
pub out_len: u64,
pub raw_data: String,
}
impl Block {
pub fn new() -> Block {
Block {
hash: String::new(),
height: String::new(),
time: String::new(),
version: String::new(),
weight: 0.0,
fees: 0.0,
kernels: Vec::new(),
inputs: Vec::new(),
outputs: Vec::new(),
ker_len: 0,
in_len: 0,
out_len: 0,
raw_data: String::new(),
}
}
}
// Transactions data
#[derive(Debug)]
pub struct Transactions {
pub period_1h: String,
pub period_24h: String,
pub fees_1h: String,
pub fees_24h: String,
}
impl Transactions {
pub fn new() -> Transactions {
Transactions {
period_1h: String::new(),
period_24h: String::new(),
fees_1h: String::new(),
fees_24h: String::new(),
}
}
}
// Explorer configuration
#[derive(Debug)]
pub struct ExplorerConfig {
pub ip: String,
pub port: String,
pub proto: String,
pub user: String,
pub api_secret_path: String,
pub foreign_api_secret_path: String,
pub api_secret: String,
pub foreign_api_secret: String,
}
impl ExplorerConfig {
pub fn new() -> ExplorerConfig {
ExplorerConfig {
ip: String::new(),
port: String::new(),
proto: String::new(),
user: String::new(),
api_secret_path: String::new(),
foreign_api_secret_path: String::new(),
api_secret: String::new(),
foreign_api_secret: String::new(),
}
}
}