validator: returning empty topology json ready to be filled up from data

This commit is contained in:
Dave Hrycyszyn
2020-03-16 18:02:20 +00:00
parent 4095f33fca
commit fced1159ce
5 changed files with 46 additions and 8 deletions
+1
View File
@@ -1,6 +1,7 @@
use iron::prelude::*;
use router::Router;
mod models;
mod routes;
pub struct Api {}
+1
View File
@@ -0,0 +1 @@
pub mod presence;
@@ -0,0 +1,36 @@
use serde::{Deserialize, Serialize};
// Topology shows us the current state of the overall Nym network
#[derive(Serialize, Deserialize, Debug)]
pub struct Topology {
pub validators: Vec<Validator>,
pub mix_nodes: Vec<MixNode>,
pub service_providers: Vec<ServiceProvider>,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Validator {
host: String,
public_key: String,
version: String,
last_seen: u64,
location: String,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct MixNode {
host: String,
public_key: String,
version: String,
last_seen: u64,
location: String,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct ServiceProvider {
host: String,
public_key: String,
version: String,
last_seen: u64,
location: String,
}
-1
View File
@@ -1,5 +1,4 @@
use iron::prelude::*;
use iron::status;
use router::Router;
pub mod topology;
@@ -1,11 +1,12 @@
use super::*;
use crate::network::rest::models::presence;
pub fn get(req: &mut Request) -> IronResult<Response> {
let ref query = req
.extensions
.get::<Router>()
.unwrap()
.find("query")
.unwrap_or("foomp");
Ok(Response::with((status::Ok, *query)))
let topology = presence::Topology {
mix_nodes: Vec::<presence::MixNode>::new(),
service_providers: Vec::<presence::ServiceProvider>::new(),
validators: Vec::<presence::Validator>::new(),
};
let resp = serde_json::to_string_pretty(&topology).unwrap();
Ok(Response::with((status::Ok, resp)))
}