Use serde_utils in rewards APIs

This commit is contained in:
Michael Sproul
2023-02-08 11:21:46 +11:00
parent d79a1e12ac
commit ed7b693d8b
3 changed files with 13 additions and 13 deletions

View File

@@ -6,26 +6,26 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct IdealAttestationRewards { pub struct IdealAttestationRewards {
// Validator's effective balance in gwei // Validator's effective balance in gwei
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "serde_utils::quoted_u64")]
pub effective_balance: u64, pub effective_balance: u64,
// Ideal attester's reward for head vote in gwei // Ideal attester's reward for head vote in gwei
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "serde_utils::quoted_u64")]
pub head: u64, pub head: u64,
// Ideal attester's reward for target vote in gwei // Ideal attester's reward for target vote in gwei
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "serde_utils::quoted_u64")]
pub target: u64, pub target: u64,
// Ideal attester's reward for source vote in gwei // Ideal attester's reward for source vote in gwei
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "serde_utils::quoted_u64")]
pub source: u64, pub source: u64,
} }
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct TotalAttestationRewards { pub struct TotalAttestationRewards {
// one entry for every validator based on their attestations in the epoch // one entry for every validator based on their attestations in the epoch
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "serde_utils::quoted_u64")]
pub validator_index: u64, pub validator_index: u64,
// attester's reward for head vote in gwei // attester's reward for head vote in gwei
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "serde_utils::quoted_u64")]
pub head: u64, pub head: u64,
// attester's reward for target vote in gwei // attester's reward for target vote in gwei
pub target: i64, pub target: i64,

View File

@@ -5,22 +5,22 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] #[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub struct StandardBlockReward { pub struct StandardBlockReward {
// proposer of the block, the proposer index who receives these rewards // proposer of the block, the proposer index who receives these rewards
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "serde_utils::quoted_u64")]
pub proposer_index: u64, pub proposer_index: u64,
// total block reward in gwei, // total block reward in gwei,
// equal to attestations + sync_aggregate + proposer_slashings + attester_slashings // equal to attestations + sync_aggregate + proposer_slashings + attester_slashings
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "serde_utils::quoted_u64")]
pub total: u64, pub total: u64,
// block reward component due to included attestations in gwei // block reward component due to included attestations in gwei
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "serde_utils::quoted_u64")]
pub attestations: u64, pub attestations: u64,
// block reward component due to included sync_aggregate in gwei // block reward component due to included sync_aggregate in gwei
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "serde_utils::quoted_u64")]
pub sync_aggregate: u64, pub sync_aggregate: u64,
// block reward component due to included proposer_slashings in gwei // block reward component due to included proposer_slashings in gwei
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "serde_utils::quoted_u64")]
pub proposer_slashings: u64, pub proposer_slashings: u64,
// block reward component due to included attester_slashings in gwei // block reward component due to included attester_slashings in gwei
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "serde_utils::quoted_u64")]
pub attester_slashings: u64, pub attester_slashings: u64,
} }

View File

@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] #[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub struct SyncCommitteeReward { pub struct SyncCommitteeReward {
#[serde(with = "eth2_serde_utils::quoted_u64")] #[serde(with = "serde_utils::quoted_u64")]
pub validator_index: u64, pub validator_index: u64,
// sync committee reward in gwei for the validator // sync committee reward in gwei for the validator
pub reward: i64, pub reward: i64,