diff options
author | Matt Harrison <hi@matt-harrison.com> | 2019-06-11 15:34:39 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-06-11 10:34:39 -0400 |
commit | d82c1991cf0919c312b87501bc588cf17781b32f (patch) | |
tree | 1cca87de6af963c379187726468eef8f47741d70 /cli/ops.rs | |
parent | cb581620522febe618cbf084b0dc3428479e84a9 (diff) |
Add --seed for setting RNG seed (#2483)
Diffstat (limited to 'cli/ops.rs')
-rw-r--r-- | cli/ops.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/cli/ops.rs b/cli/ops.rs index f39daaab6..61f29ac9f 100644 --- a/cli/ops.rs +++ b/cli/ops.rs @@ -2211,10 +2211,17 @@ fn op_host_post_message( } fn op_get_random_values( - _state: &ThreadSafeState, + state: &ThreadSafeState, _base: &msg::Base<'_>, data: Option<PinnedBuf>, ) -> Box<OpWithError> { - thread_rng().fill(&mut data.unwrap()[..]); + if let Some(ref seeded_rng) = state.seeded_rng { + let mut rng = seeded_rng.lock().unwrap(); + rng.fill(&mut data.unwrap()[..]); + } else { + let mut rng = thread_rng(); + rng.fill(&mut data.unwrap()[..]); + } + Box::new(ok_future(empty_buf())) } |