implemented the noise route
This commit is contained in:
@@ -9,7 +9,10 @@ use crate::nym_nodes::{BasicEntryInformation, NodeRole, SkimmedNode};
|
||||
use crate::pagination::PaginatedResponse;
|
||||
use cosmwasm_std::{Addr, Coin, Decimal, Uint128};
|
||||
use nym_crypto::asymmetric::ed25519::{self, serde_helpers::bs58_ed25519_pubkey};
|
||||
use nym_crypto::asymmetric::x25519::{self, serde_helpers::bs58_x25519_pubkey};
|
||||
use nym_crypto::asymmetric::x25519::{
|
||||
self,
|
||||
serde_helpers::{bs58_x25519_pubkey, option_bs58_x25519_pubkey},
|
||||
};
|
||||
use nym_mixnet_contract_common::nym_node::Role;
|
||||
use nym_mixnet_contract_common::reward_params::{Performance, RewardingParams};
|
||||
use nym_mixnet_contract_common::rewarding::RewardEstimate;
|
||||
@@ -586,6 +589,11 @@ pub struct HostKeys {
|
||||
#[serde(with = "bs58_x25519_pubkey")]
|
||||
#[schemars(with = "String")]
|
||||
pub x25519: x25519::PublicKey,
|
||||
|
||||
#[serde(default)]
|
||||
#[serde(with = "option_bs58_x25519_pubkey")]
|
||||
#[schemars(with = "Option<String>")]
|
||||
pub x25519_noise: Option<x25519::PublicKey>,
|
||||
}
|
||||
|
||||
impl From<nym_node_requests::api::v1::node::models::HostKeys> for HostKeys {
|
||||
@@ -593,6 +601,7 @@ impl From<nym_node_requests::api::v1::node::models::HostKeys> for HostKeys {
|
||||
HostKeys {
|
||||
ed25519: value.ed25519_identity,
|
||||
x25519: value.x25519_sphinx,
|
||||
x25519_noise: value.x25519_noise,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-20
@@ -69,18 +69,6 @@ impl CachedRewardedSet {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn active_set_size(&self) -> usize {
|
||||
self.entry_gateways.len()
|
||||
+ self.exit_gateways.len()
|
||||
+ self.layer1.len()
|
||||
+ self.layer2.len()
|
||||
+ self.layer3.len()
|
||||
}
|
||||
|
||||
pub fn rewarded_set_size(&self) -> usize {
|
||||
self.active_set_size() + self.standby.len()
|
||||
}
|
||||
|
||||
pub fn try_get_mix_layer(&self, node_id: &NodeId) -> Option<u8> {
|
||||
if self.layer1.contains(node_id) {
|
||||
Some(1)
|
||||
@@ -97,20 +85,13 @@ impl CachedRewardedSet {
|
||||
self.standby.contains(node_id)
|
||||
}
|
||||
|
||||
pub fn is_entry(&self, node_id: &NodeId) -> bool {
|
||||
self.entry_gateways.contains(node_id)
|
||||
}
|
||||
|
||||
pub fn is_exit(&self, node_id: &NodeId) -> bool {
|
||||
self.exit_gateways.contains(node_id)
|
||||
}
|
||||
|
||||
pub fn is_active_mixnode(&self, node_id: &NodeId) -> bool {
|
||||
self.layer1.contains(node_id)
|
||||
|| self.layer2.contains(node_id)
|
||||
|| self.layer3.contains(node_id)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn gateways(&self) -> HashSet<NodeId> {
|
||||
let mut gateways =
|
||||
HashSet::with_capacity(self.entry_gateways.len() + self.exit_gateways.len());
|
||||
|
||||
@@ -58,7 +58,35 @@ async fn nodes_noise(
|
||||
) -> AxumResult<Json<PaginatedResponse<NoiseDetails>>> {
|
||||
// TODO: implement it
|
||||
let _ = pagination;
|
||||
todo!()
|
||||
|
||||
let describe_cache = state.describe_nodes_cache_data().await?;
|
||||
|
||||
let nodes = describe_cache
|
||||
.all_nodes()
|
||||
.filter_map(|n| {
|
||||
n.description
|
||||
.host_information
|
||||
.keys
|
||||
.x25519_noise
|
||||
.map(|noise_key| (noise_key, n))
|
||||
})
|
||||
.map(|(noise_key, node)| NoiseDetails {
|
||||
x25119_pubkey: noise_key,
|
||||
mixnet_port: node.description.mix_port(),
|
||||
ip_addresses: node.description.host_information.ip_address.clone(),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let total = nodes.len();
|
||||
|
||||
Ok(Json(PaginatedResponse {
|
||||
pagination: Pagination {
|
||||
total,
|
||||
page: 0,
|
||||
size: total,
|
||||
},
|
||||
data: nodes,
|
||||
}))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
|
||||
Reference in New Issue
Block a user