Skip to content

Instantly share code, notes, and snippets.

@rogerwilcos rogerwilcos/lifetime.rs Secret
Last active Jun 4, 2018

Embed
What would you like to do?
How does it works?
#[macro_use]
extern crate serde_derive;
extern crate serde;
#[macro_use]
extern crate serde_json;
extern crate exonum;
use exonum::crypto::{self, CryptoHash, Hash, PublicKey, SecretKey};
#[derive(Serialize, Debug)]
struct BodyJson<'a> {
pub_key: &'a PublicKey,
act_id: &'a str,
form_act_id: &'a str,
block: &'a str,
status: &'a str,
}
#[derive(Serialize, Debug)]
struct FullJson<'b> {
network_id: &'b str,
protocol_version: &'b str,
service_id: &'b str,
message_id: &'b str,
signature: exonum::crypto::SecretKey,
body: &'b BodyJson<'b>,
}
fn high_load(api_address: hyper::Uri) -> u64 {
let mut count: u64 = 0;
let keypair = crypto::gen_keypair();
while count < 10 {
let payload = FullJson {
network_id: NETWORK_ID.to_string(),
protocol_version: PROTOCOL_VERSION.to_string(),
service_id: SERVICE_ID.to_string(),
message_id: MESSAGE_ID.to_string(),
signature: keypair.1,
body: &BodyJson {
pub_key: &keypair.0,
act_id: &count.to_string(),
form_act_id: &count.to_string(),
block: &count.to_string(),
status: &count.to_string(),
},
};
post_json(
serde_json::Value::String(serde_json::to_string(&payload).unwrap()),
api_address.clone(),
&keypair,
);
count = count + 1;
}
return count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.