<commit_before>use super::utils::types::*;

pub struct RecentPropserRecord {
    pub index: u32,     // TODO: make u24
    pub randao_commitment: Sha256Digest,
    pub balance_delta: u32, // TODO: make u24
}

impl RecentPropserRecord {
    pub fn new(index: u32, 
               randao_commitment: Sha256Digest, 
               balance_delta: u32) -> RecentPropserRecord {
        RecentPropserRecord {
            index: index,
            randao_commitment: randao_commitment,
            balance_delta: balance_delta
        }
    }
}<commit_msg>Add RLP encoding to RecentProposerRecord<commit_after>use super::rlp::{ RlpStream, Encodable };
use super::utils::types::*;

pub struct RecentPropserRecord {
    pub index: u32,     // TODO: make u24
    pub randao_commitment: Sha256Digest,
    pub balance_delta: u32, // TODO: make u24
}

impl RecentPropserRecord {
    pub fn new(index: u32, 
               randao_commitment: Sha256Digest, 
               balance_delta: u32) -> RecentPropserRecord {
        RecentPropserRecord {
            index: index,
            randao_commitment: randao_commitment,
            balance_delta: balance_delta
        }
    }
}

/*
 * RLP Encoding
 */
impl Encodable for RecentPropserRecord {
    fn rlp_append(&self, s: &mut RlpStream) {
        s.append(&self.index);
        s.append(&self.randao_commitment);
        s.append(&self.balance_delta);
    }
}


#[cfg(test)]
mod tests {
    use super::super::rlp;
    use super::*;

    #[test]
    fn test_serialization() {
        let index = 1;
        let randao_commitment = Sha256Digest::zero();
        let balance_delta = 99;
        let r = RecentPropserRecord::new(index, randao_commitment, balance_delta);
        let e = rlp::encode(&r);
        assert_eq!(e[0], 1);
        assert_eq!(e[1], 160);
        assert_eq!(e[2..34], [0; 32]);
        assert_eq!(e[34], 99);
    }
}
{'fraction_non_alphanumeric': 0.11294619072988812, 'fraction_numerical': 0.03090037293553543, 'mean_word_length': 2.4649446494464944, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5432252', 'n_tokens_mistral': 640, 'n_tokens_neox': 611, 'n_words': 134}