message: [consensus] refactor SafetyRulesManager
  Some of this helper code can be reused without needing to generate an
  object, so separating it accordingly.
  Closes:
  Approved by: davidiw
diff: @@ -14,18 +14,9 @@ use libra_config::config::{NodeConfig, SafetyRulesBackend, SafetyRulesService};
  use libra_types::crypto_proxies::ValidatorSigner;
  use std::sync::{Arc, RwLock};
  -enum SafetyRulesWrapper<T> {
  - Local(Arc<RwLock<SafetyRules<T>>>),
  - Serializer(Arc<RwLock<SerializerService<T>>>),
  - Thread(ThreadService<T>),
  -}
  -
  -pub struct SafetyRulesManager<T> {
  - internal_safety_rules: SafetyRulesWrapper<T>,
  -}
  -
  -impl<T: Payload> SafetyRulesManager<T> {
  - pub fn new(config: &mut NodeConfig) -> Self {
  +pub fn extract_service_inputs(
  + config: &mut NodeConfig,
  +) -> (ValidatorSigner, Box<dyn PersistentStorage>) {
  let private_key = config
  .test
  .as_mut()
  @@ -44,8 +35,7 @@ impl<T: Payload> SafetyRulesManager<T> {
  let validator_signer = ValidatorSigner::new(author, private_key);
  - let sr_config = &config.consensus.safety_rules;
  - let storage = match &sr_config.backend {
  + let storage = match &config.consensus.safety_rules.backend {
  SafetyRulesBackend::InMemoryStorage => InMemoryStorage::default_storage(),
  SafetyRulesBackend::OnDiskStorage(config) => {
  if config.default {
  @@ -58,6 +48,23 @@ impl<T: Payload> SafetyRulesManager<T> {
  }
  };
  + (validator_signer, storage)
  +}
  +
  +enum SafetyRulesWrapper<T> {
  + Local(Arc<RwLock<SafetyRules<T>>>),
  + Serializer(Arc<RwLock<SerializerService<T>>>),
  + Thread(ThreadService<T>),
  +}
  +
  +pub struct SafetyRulesManager<T> {
  + internal_safety_rules: SafetyRulesWrapper<T>,
  +}
  +
  +impl<T: Payload> SafetyRulesManager<T> {
  + pub fn new(config: &mut NodeConfig) -> Self {
  + let (validator_signer, storage) = extract_service_inputs(config);
  + let sr_config = &config.consensus.safety_rules;
  match sr_config.service {
  SafetyRulesService::Local => Self::new_local(storage, validator_signer),
  SafetyRulesService::Serializer => Self::new_serializer(storage, validator_signer),
  @@ -111,6 +118,7 @@ impl<T: Payload> SafetyRulesManager<T> {
  Box::new(SerializerClient::new(serializer_service.clone()))
  }
  SafetyRulesWrapper::Thread(thread) => Box::new(thread.client()),
  + _ => panic!("Unable to retrieve client for this service"),
  }
  }
  }
  