From b1066509c1d4479bb1df8051f3e2a2ce8f716117 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Fri, 13 Jul 2018 15:35:48 +1000 Subject: [PATCH] Add zero method to ValidatorRecord --- src/state/validator_record.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/state/validator_record.rs b/src/state/validator_record.rs index 5835437c8..f03b43b0c 100644 --- a/src/state/validator_record.rs +++ b/src/state/validator_record.rs @@ -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 + } + } } /*