Feature/downcast reward estimation (#1031)

* Downcast u128 to u64

* fmt

* Fix status

* fmt
This commit is contained in:
Drazen Urch
2022-01-14 20:57:51 +01:00
committed by GitHub
parent 44d59ff8c2
commit 8fb54dd4e7
4 changed files with 39 additions and 22 deletions
+22 -12
View File
@@ -131,18 +131,28 @@ pub(crate) async fn get_mixnode_reward_estimation(
.await
.map_err(|err| ErrorResponse::new(err.to_string(), Status::NotFound))?;
let (estimated_total_node_reward, estimated_operator_reward, estimated_delegators_reward) =
epoch_reward_params.estimate_reward(&bond, uptime.u8(), status.is_active());
Ok(Json(RewardEstimationResponse {
estimated_total_node_reward,
estimated_operator_reward,
estimated_delegators_reward,
current_epoch_start: current_epoch.start_unix_timestamp(),
current_epoch_end: current_epoch.end_unix_timestamp(),
current_epoch_uptime: uptime.u8(),
as_at,
}))
match epoch_reward_params.estimate_reward(&bond, uptime.u8(), status.is_active()) {
Ok((
estimated_total_node_reward,
estimated_operator_reward,
estimated_delegators_reward,
)) => {
let reponse = RewardEstimationResponse {
estimated_total_node_reward,
estimated_operator_reward,
estimated_delegators_reward,
current_epoch_start: current_epoch.start_unix_timestamp(),
current_epoch_end: current_epoch.end_unix_timestamp(),
current_epoch_uptime: uptime.u8(),
as_at,
};
Ok(Json(reponse))
}
Err(e) => Err(ErrorResponse::new(
e.to_string(),
Status::InternalServerError,
)),
}
} else {
Err(ErrorResponse::new(
"mixnode bond not found",