From 82f05b7d745e4cd5ee3ee3df225342cd4deb5548 Mon Sep 17 00:00:00 2001 From: jstuczyn Date: Fri, 6 Nov 2020 16:24:06 +0000 Subject: [PATCH] Updated validator topology --- .../validator-client/src/models/mod.rs | 1 + .../validator-client/src/models/topology.rs | 2 ++ .../validator-client/src/models/validators.rs | 29 +++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 common/client-libs/validator-client/src/models/validators.rs diff --git a/common/client-libs/validator-client/src/models/mod.rs b/common/client-libs/validator-client/src/models/mod.rs index 3a87b13e7c4..f6076854b1e 100644 --- a/common/client-libs/validator-client/src/models/mod.rs +++ b/common/client-libs/validator-client/src/models/mod.rs @@ -17,3 +17,4 @@ pub mod mixmining; pub mod mixnode; mod node; pub mod topology; +pub mod validators; diff --git a/common/client-libs/validator-client/src/models/topology.rs b/common/client-libs/validator-client/src/models/topology.rs index 916d1c7e0f3..5ec5617bb85 100644 --- a/common/client-libs/validator-client/src/models/topology.rs +++ b/common/client-libs/validator-client/src/models/topology.rs @@ -14,6 +14,7 @@ use crate::models::gateway::RegisteredGateway; use crate::models::mixnode::RegisteredMix; +use crate::models::validators::ValidatorsOutput; use log::*; use serde::{Deserialize, Serialize}; use std::convert::TryInto; @@ -25,6 +26,7 @@ use topology::{MixLayer, NymTopology}; pub struct Topology { pub mix_nodes: Vec, pub gateways: Vec, + pub validators: ValidatorsOutput, } // changed from `TryInto`. reason being is that we should not fail entire topology diff --git a/common/client-libs/validator-client/src/models/validators.rs b/common/client-libs/validator-client/src/models/validators.rs new file mode 100644 index 00000000000..511ace0d19b --- /dev/null +++ b/common/client-libs/validator-client/src/models/validators.rs @@ -0,0 +1,29 @@ +// Copyright 2020 Nym Technologies SA +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct ValidatorsOutput { + pub(crate) block_height: i64, + pub(crate) validators: Vec, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +pub(crate) struct ValidatorOutput { + pub(crate) address: String, + pub(crate) pub_key: String, + pub(crate) proposer_priority: i64, + pub(crate) voting_power: i64, +}