Remove old MixnodeToReward struct

This commit is contained in:
Bogdan-Ștefan Neacșu
2023-07-17 13:25:31 +03:00
parent 57e72d52c8
commit 0809cdc169
4 changed files with 5 additions and 24 deletions
+2 -2
View File
@@ -12,9 +12,9 @@ use crate::ephemera::epoch::Epoch;
use crate::ephemera::peers::members::MembersProvider;
use crate::ephemera::peers::{NymApiEphemeraPeerInfo, NymPeer};
use crate::ephemera::reward::aggregator::RewardsAggregator;
use crate::ephemera::reward::MixnodeToReward;
use crate::ephemera::reward::{EphemeraAccess, RewardManager};
use crate::ephemera::Args;
use crate::epoch_operations::MixnodeWithPerformance;
use crate::support::nyxd;
use ephemera::crypto::{EphemeraKeypair, EphemeraPublicKey, Keypair};
use ephemera::ephemera_api::CommandExecutor;
@@ -164,7 +164,7 @@ impl Application for RewardsEphemeraApplication {
/// - Check that the transaction has a valid signature, we don't want to accept garbage messages
/// or messages from unknown peers
fn check_tx(&self, tx: ApiEphemeraMessage) -> ApplicationResult<bool> {
if serde_json::from_slice::<Vec<MixnodeToReward>>(&tx.data).is_err() {
if serde_json::from_slice::<Vec<MixnodeWithPerformance>>(&tx.data).is_err() {
error!("Message is not a valid Reward message");
return Ok(false);
}
+1 -2
View File
@@ -1,4 +1,3 @@
use crate::ephemera::reward::MixnodeToReward;
use cosmwasm_std::Decimal;
use log::{info, trace};
use nym_mixnet_contract_common::reward_params::Performance;
@@ -12,7 +11,7 @@ impl RewardsAggregator {
//Simple mean average
pub(crate) fn aggregate(
&self,
all_rewards: Vec<Vec<MixnodeToReward>>,
all_rewards: Vec<Vec<MixnodeWithPerformance>>,
) -> anyhow::Result<Vec<MixnodeWithPerformance>> {
let mut mix_rewards = HashMap::new();
for api_rewards in all_rewards {
+2 -10
View File
@@ -1,6 +1,5 @@
use async_trait::async_trait;
use log::{debug, info, trace};
use serde::{Deserialize, Serialize};
use std::time::Duration;
use crate::epoch_operations::MixnodeWithPerformance;
@@ -8,8 +7,6 @@ use ephemera::{
crypto::Keypair,
ephemera_api::{self, ApiBlock, ApiEphemeraMessage, ApiError, CommandExecutor},
};
use nym_mixnet_contract_common::reward_params::Performance;
use nym_mixnet_contract_common::MixId;
use super::epoch::Epoch;
use super::reward::aggregator::RewardsAggregator;
@@ -17,12 +14,6 @@ use super::Args;
pub(crate) mod aggregator;
#[derive(Debug, Clone, Copy, Deserialize, Serialize)]
pub struct MixnodeToReward {
pub mix_id: MixId,
pub performance: Performance,
}
pub struct EphemeraAccess {
pub(crate) api: CommandExecutor,
pub(crate) key_pair: Keypair,
@@ -255,7 +246,8 @@ where
for message in block.messages {
trace!("Message: {}", message);
let mix_node_reward: Vec<MixnodeToReward> = serde_json::from_slice(&message.data)?;
let mix_node_reward: Vec<MixnodeWithPerformance> =
serde_json::from_slice(&message.data)?;
mix_node_rewards.push(mix_node_reward);
}
-10
View File
@@ -1,7 +1,6 @@
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use crate::ephemera::reward::MixnodeToReward;
use crate::epoch_operations::RewardedSetUpdater;
use cosmwasm_std::{Decimal, Fraction};
use nym_mixnet_contract_common::reward_params::Performance;
@@ -15,15 +14,6 @@ pub(crate) struct MixnodeWithPerformance {
pub(crate) performance: Performance,
}
impl From<MixnodeToReward> for MixnodeWithPerformance {
fn from(value: MixnodeToReward) -> Self {
Self {
mix_id: value.mix_id,
performance: value.performance,
}
}
}
impl From<MixnodeWithPerformance> for ExecuteMsg {
fn from(mix_reward: MixnodeWithPerformance) -> Self {
ExecuteMsg::RewardMixnode {