1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use super::RpcAddress;
use cfx_types::{H256, U256};
use cfxcore::block_data_manager::BlockRewardResult;
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RewardInfo {
    block_hash: H256,
    author: RpcAddress,
    total_reward: U256,
    base_reward: U256,
    tx_fee: U256,
}

impl RewardInfo {
    pub fn new(
        block_hash: H256, author: RpcAddress, reward_result: BlockRewardResult,
    ) -> Self {
        RewardInfo {
            block_hash: block_hash.into(),
            author,
            total_reward: reward_result.total_reward.into(),
            base_reward: reward_result.base_reward.into(),
            tx_fee: reward_result.tx_fee.into(),
        }
    }
}