Add zero method to ValidatorRecord

This commit is contained in:
Paul Hauner 2018-07-13 15:35:48 +10:00
parent b1b2337ec3
commit b1066509c1

View File

@ -1,7 +1,11 @@
extern crate rand;
use super::utils::types::{ Sha256Digest, Address, U256 };
use super::utils::bls::PublicKey;
use super::utils::bls::{ PublicKey, Keypair };
use super::rlp::{ RlpStream, Encodable };
use self::rand::thread_rng;
pub struct ValidatorRecord {
pub pubkey: PublicKey,
pub withdrawal_shard: u16,
@ -29,6 +33,19 @@ impl ValidatorRecord {
switch_dynasty
}
}
pub fn zero_with_thread_rand_pub_key() -> Self {
let mut rng = thread_rng();
let keypair = Keypair::generate(&mut rng);
Self {
pubkey: keypair.public,
withdrawal_shard: 0,
withdrawal_address: Address::zero(),
randao_commitment: Sha256Digest::zero(),
balance: U256::zero(),
switch_dynasty: 0
}
}
}
/*