Removed gateway rewarding and delegation (#856)
* Removed gateway rewarding and delegation * Removed redundant error variants * [ci skip] Generate TS types * Test fixes Co-authored-by: jstuczyn <jstuczyn@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
ef88ce9252
commit
b19528d47e
@@ -5,8 +5,8 @@ use crate::network_monitor::monitor::summary_producer::NodeResult;
|
||||
use crate::node_status_api::models::{HistoricalUptime, Uptime};
|
||||
use crate::node_status_api::utils::ActiveNodeDayStatuses;
|
||||
use crate::storage::models::{
|
||||
ActiveNode, EpochRewarding, FailedGatewayRewardChunk, FailedMixnodeRewardChunk, NodeStatus,
|
||||
PossiblyUnrewardedGateway, PossiblyUnrewardedMixnode, RewardingReport,
|
||||
ActiveNode, EpochRewarding, FailedMixnodeRewardChunk, NodeStatus, PossiblyUnrewardedMixnode,
|
||||
RewardingReport,
|
||||
};
|
||||
use crate::storage::UnixTimestamp;
|
||||
use std::convert::TryFrom;
|
||||
@@ -791,17 +791,15 @@ impl StorageManager {
|
||||
sqlx::query!(
|
||||
r#"
|
||||
INSERT INTO rewarding_report
|
||||
(epoch_rewarding_id, eligible_mixnodes, eligible_gateways, possibly_unrewarded_mixnodes, possibly_unrewarded_gateways)
|
||||
VALUES (?, ?, ?, ?, ?);
|
||||
(epoch_rewarding_id, eligible_mixnodes, possibly_unrewarded_mixnodes)
|
||||
VALUES (?, ?, ?);
|
||||
"#,
|
||||
report.epoch_rewarding_id,
|
||||
report.eligible_mixnodes,
|
||||
report.eligible_gateways,
|
||||
report.possibly_unrewarded_mixnodes,
|
||||
report.possibly_unrewarded_gateways,
|
||||
)
|
||||
.execute(&self.connection_pool)
|
||||
.await?;
|
||||
.execute(&self.connection_pool)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -826,27 +824,6 @@ impl StorageManager {
|
||||
Ok(res.last_insert_rowid())
|
||||
}
|
||||
|
||||
/// Inserts new failed gateway reward chunk information into the database.
|
||||
/// Returns id of the newly created entry.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `failed_chunk`: chunk information to insert.
|
||||
pub(super) async fn insert_failed_gateway_reward_chunk(
|
||||
&self,
|
||||
failed_chunk: FailedGatewayRewardChunk,
|
||||
) -> Result<i64, sqlx::Error> {
|
||||
let res = sqlx::query!(
|
||||
r#"
|
||||
INSERT INTO failed_gateway_reward_chunk (error_message, reward_summary_id) VALUES (?, ?)
|
||||
"#,
|
||||
failed_chunk.error_message,
|
||||
failed_chunk.epoch_rewarding_id,
|
||||
).execute(&self.connection_pool).await?;
|
||||
|
||||
Ok(res.last_insert_rowid())
|
||||
}
|
||||
|
||||
/// Inserts information into the database about a mixnode that might have been unfairly unrewarded this epoch.
|
||||
///
|
||||
/// # Arguments
|
||||
@@ -867,26 +844,6 @@ impl StorageManager {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Inserts information into the database about a gateway that might have been unfairly unrewarded this epoch.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `gateway`: mixnode information to insert.
|
||||
pub(super) async fn insert_possibly_unrewarded_gateway(
|
||||
&self,
|
||||
gateway: PossiblyUnrewardedGateway,
|
||||
) -> Result<(), sqlx::Error> {
|
||||
sqlx::query!(
|
||||
r#"
|
||||
INSERT INTO possibly_unrewarded_gateway (identity, uptime, failed_gateway_reward_chunk_id) VALUES (?, ?, ?)
|
||||
"#,
|
||||
gateway.identity,
|
||||
gateway.uptime,
|
||||
gateway.chunk_id
|
||||
).execute(&self.connection_pool).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Obtains all statuses of active mixnodes from the specified time interval.
|
||||
///
|
||||
/// # Arguments
|
||||
|
||||
@@ -9,8 +9,8 @@ use crate::node_status_api::models::{
|
||||
use crate::node_status_api::{ONE_DAY, ONE_HOUR};
|
||||
use crate::storage::manager::StorageManager;
|
||||
use crate::storage::models::{
|
||||
EpochRewarding, FailedGatewayRewardChunk, FailedMixnodeRewardChunk, NodeStatus,
|
||||
PossiblyUnrewardedGateway, PossiblyUnrewardedMixnode, RewardingReport,
|
||||
EpochRewarding, FailedMixnodeRewardChunk, NodeStatus, PossiblyUnrewardedMixnode,
|
||||
RewardingReport,
|
||||
};
|
||||
use rocket::fairing::{self, AdHoc};
|
||||
use rocket::{Build, Rocket};
|
||||
@@ -648,22 +648,6 @@ impl NodeStatusStorage {
|
||||
.map_err(|_| NodeStatusApiError::InternalDatabaseError)
|
||||
}
|
||||
|
||||
/// Inserts new failed gateway reward chunk information into the database.
|
||||
/// Returns id of the newly created entry.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `failed_chunk`: chunk information to insert.
|
||||
pub(crate) async fn insert_failed_gateway_reward_chunk(
|
||||
&self,
|
||||
failed_chunk: FailedGatewayRewardChunk,
|
||||
) -> Result<i64, NodeStatusApiError> {
|
||||
self.manager
|
||||
.insert_failed_gateway_reward_chunk(failed_chunk)
|
||||
.await
|
||||
.map_err(|_| NodeStatusApiError::InternalDatabaseError)
|
||||
}
|
||||
|
||||
/// Inserts information into the database about a mixnode that might have been unfairly unrewarded this epoch.
|
||||
///
|
||||
/// # Arguments
|
||||
@@ -678,19 +662,4 @@ impl NodeStatusStorage {
|
||||
.await
|
||||
.map_err(|_| NodeStatusApiError::InternalDatabaseError)
|
||||
}
|
||||
|
||||
/// Inserts information into the database about a gateway that might have been unfairly unrewarded this epoch.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `gateway`: mixnode information to insert.
|
||||
pub(crate) async fn insert_possibly_unrewarded_gateway(
|
||||
&self,
|
||||
gateway: PossiblyUnrewardedGateway,
|
||||
) -> Result<(), NodeStatusApiError> {
|
||||
self.manager
|
||||
.insert_possibly_unrewarded_gateway(gateway)
|
||||
.await
|
||||
.map_err(|_| NodeStatusApiError::InternalDatabaseError)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,8 @@ pub(crate) struct RewardingReport {
|
||||
pub(crate) epoch_rewarding_id: i64,
|
||||
|
||||
pub(crate) eligible_mixnodes: i64,
|
||||
pub(crate) eligible_gateways: i64,
|
||||
|
||||
pub(crate) possibly_unrewarded_mixnodes: i64,
|
||||
pub(crate) possibly_unrewarded_gateways: i64,
|
||||
}
|
||||
|
||||
pub(crate) struct FailedMixnodeRewardChunk {
|
||||
@@ -47,16 +45,3 @@ pub(crate) struct PossiblyUnrewardedMixnode {
|
||||
pub(crate) identity: String,
|
||||
pub(crate) uptime: u8,
|
||||
}
|
||||
|
||||
pub(crate) struct FailedGatewayRewardChunk {
|
||||
// references particular epoch_rewarding (there can be multiple chunks in a rewarding epoch)
|
||||
pub(crate) epoch_rewarding_id: i64,
|
||||
pub(crate) error_message: String,
|
||||
}
|
||||
|
||||
pub(crate) struct PossiblyUnrewardedGateway {
|
||||
// references particular FailedGatewayRewardChunk (there can be multiple nodes in a chunk)
|
||||
pub(crate) chunk_id: i64,
|
||||
pub(crate) identity: String,
|
||||
pub(crate) uptime: u8,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user