<commit_before>extern crate digest;
extern crate hex;
extern crate rand;
extern crate rust_base58;
extern crate sha2;
extern crate time;
extern crate rmp_serde;
extern crate indy_crypto;

use base64;
use self::digest::{FixedOutput, Input};
use self::hex::ToHex;
use self::rand::Rng;
use self::rust_base58::FromBase58;
use self::time::{Duration, Tm};
use serde_json;
use serde_json::Value as SJsonValue;
use std::collections::HashMap;
use std::error::Error;
use std::ops::Add;

use super::state_proof;
use commands::{Command, CommandExecutor};
use commands::ledger::LedgerCommand;
use errors::pool::PoolError;
use errors::common::CommonError;
use super::types::*;
use services::ledger::constants;
use services::ledger::merkletree::merkletree::MerkleTree;
use self::indy_crypto::bls::Generator;

const REQUESTS_FOR_STATE_PROOFS: [&'static str; 4] = [constants::GET_NYM, constants::GET_SCHEMA, constants::GET_CLAIM_DEF, constants::GET_ATTR];
const RESENDABLE_REQUEST_TIMEOUT: i64 = 1;
const REQUEST_TIMEOUT_ACK: i64 = 10;
const REQUEST_TIMEOUT_REPLY: i64 = 2000;

pub struct TransactionHandler {
    gen: Generator,
    pub f: usize,
    pub nodes: Vec<RemoteNode>,
    pending_commands: HashMap<u64 /* requestId */, CommandProcess>,
}

impl TransactionHandler {
    pub fn process_msg(&mut self, msg: Message, raw_msg: &String, src_ind: usize) -> Result<Option<MerkleTree>, PoolError> {
        match msg {
            Message::Reply(reply) => {
                self.process_reply(reply.result.req_id, raw_msg);
            }
            Message::Reject(response) | Message::ReqNACK(response) => {
                self.process_reject(&response, raw_msg);
            }
            Message::ReqACK(ack) => {
                self.process_ack(&ack, raw_msg);
            }
            _ => {
                warn!("unhandled msg {:?}", msg);
            }
        };<commit_msg>Request time was decreased from 2000 to 100 seconds<commit_after>extern crate digest;
extern crate hex;
extern crate rand;
extern crate rust_base58;
extern crate sha2;
extern crate time;
extern crate rmp_serde;
extern crate indy_crypto;

use base64;
use self::digest::{FixedOutput, Input};
use self::hex::ToHex;
use self::rand::Rng;
use self::rust_base58::FromBase58;
use self::time::{Duration, Tm};
use serde_json;
use serde_json::Value as SJsonValue;
use std::collections::HashMap;
use std::error::Error;
use std::ops::Add;

use super::state_proof;
use commands::{Command, CommandExecutor};
use commands::ledger::LedgerCommand;
use errors::pool::PoolError;
use errors::common::CommonError;
use super::types::*;
use services::ledger::constants;
use services::ledger::merkletree::merkletree::MerkleTree;
use self::indy_crypto::bls::Generator;

const REQUESTS_FOR_STATE_PROOFS: [&'static str; 4] = [constants::GET_NYM, constants::GET_SCHEMA, constants::GET_CLAIM_DEF, constants::GET_ATTR];
const RESENDABLE_REQUEST_TIMEOUT: i64 = 1;
const REQUEST_TIMEOUT_ACK: i64 = 10;
const REQUEST_TIMEOUT_REPLY: i64 = 100;

pub struct TransactionHandler {
    gen: Generator,
    pub f: usize,
    pub nodes: Vec<RemoteNode>,
    pending_commands: HashMap<u64 /* requestId */, CommandProcess>,
}

impl TransactionHandler {
    pub fn process_msg(&mut self, msg: Message, raw_msg: &String, src_ind: usize) -> Result<Option<MerkleTree>, PoolError> {
        match msg {
            Message::Reply(reply) => {
                self.process_reply(reply.result.req_id, raw_msg);
            }
            Message::Reject(response) | Message::ReqNACK(response) => {
                self.process_reject(&response, raw_msg);
            }
            Message::ReqACK(ack) => {
                self.process_ack(&ack, raw_msg);
            }
            _ => {
                warn!("unhandled msg {:?}", msg);
            }
        };
{'fraction_non_alphanumeric': 0.13058419243986255, 'fraction_numerical': 0.014803066349458101, 'mean_word_length': 4.052069425901202, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, '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': '3100214', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1202, 'n_words': 276}