Revert tps_demo marker
This commit is contained in:
parent
6d275d571c
commit
d698b3da3a
|
@ -415,7 +415,6 @@ fn request_airdrop(
|
|||
let req = DroneRequest::GetAirdrop {
|
||||
airdrop_request_amount: tokens,
|
||||
client_public_key: id.pubkey(),
|
||||
tps_demo: true,
|
||||
};
|
||||
let tx = serialize(&req).expect("serialize drone request");
|
||||
stream.write_all(&tx).unwrap();
|
||||
|
|
|
@ -321,7 +321,6 @@ fn request_airdrop(
|
|||
let req = DroneRequest::GetAirdrop {
|
||||
airdrop_request_amount: tokens,
|
||||
client_public_key: id.pubkey(),
|
||||
tps_demo: false,
|
||||
};
|
||||
let tx = serialize(&req).expect("serialize drone request");
|
||||
stream.write_all(&tx).unwrap();
|
||||
|
|
14
src/drone.rs
14
src/drone.rs
|
@ -13,14 +13,13 @@ use thin_client::ThinClient;
|
|||
use transaction::Transaction;
|
||||
|
||||
pub const TIME_SLICE: u64 = 60;
|
||||
pub const REQUEST_CAP: u64 = 150_000;
|
||||
pub const REQUEST_CAP: u64 = 1_000_000;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub enum DroneRequest {
|
||||
GetAirdrop {
|
||||
airdrop_request_amount: u64,
|
||||
client_public_key: PublicKey,
|
||||
tps_demo: bool,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -33,7 +32,6 @@ pub struct Drone {
|
|||
pub time_slice: Duration,
|
||||
request_cap: u64,
|
||||
pub request_current: u64,
|
||||
pub tps_request_current: bool,
|
||||
}
|
||||
|
||||
impl Drone {
|
||||
|
@ -62,7 +60,6 @@ impl Drone {
|
|||
time_slice,
|
||||
request_cap,
|
||||
request_current: 0,
|
||||
tps_request_current: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +69,6 @@ impl Drone {
|
|||
|
||||
pub fn clear_request_count(&mut self) {
|
||||
self.request_current = 0;
|
||||
self.tps_request_current = false;
|
||||
}
|
||||
|
||||
pub fn add_ip_to_cache(&mut self, ip: IpAddr) {
|
||||
|
@ -108,13 +104,11 @@ impl Drone {
|
|||
transactions_socket,
|
||||
);
|
||||
let last_id = client.get_last_id();
|
||||
let tps_check: bool;
|
||||
|
||||
match req {
|
||||
DroneRequest::GetAirdrop {
|
||||
airdrop_request_amount,
|
||||
client_public_key,
|
||||
tps_demo,
|
||||
} => {
|
||||
request_amount = airdrop_request_amount.clone();
|
||||
tx = Transaction::new(
|
||||
|
@ -123,15 +117,11 @@ impl Drone {
|
|||
airdrop_request_amount as i64,
|
||||
last_id,
|
||||
);
|
||||
tps_check = tps_demo;
|
||||
}
|
||||
}
|
||||
if self.check_request_limit(request_amount) {
|
||||
self.request_current += request_amount;
|
||||
client.transfer_signed(tx)
|
||||
} else if tps_check && !self.tps_request_current {
|
||||
self.tps_request_current = true;
|
||||
client.transfer_signed(tx)
|
||||
} else {
|
||||
Err(Error::new(ErrorKind::Other, "token limit reached"))
|
||||
}
|
||||
|
@ -284,7 +274,6 @@ mod tests {
|
|||
let bob_req = DroneRequest::GetAirdrop {
|
||||
airdrop_request_amount: 50,
|
||||
client_public_key: bob_pubkey,
|
||||
tps_demo: false,
|
||||
};
|
||||
let bob_result = drone.send_airdrop(bob_req).expect("send airdrop test");
|
||||
assert!(bob_result > 0);
|
||||
|
@ -292,7 +281,6 @@ mod tests {
|
|||
let carlos_req = DroneRequest::GetAirdrop {
|
||||
airdrop_request_amount: 5_000_000,
|
||||
client_public_key: carlos_pubkey,
|
||||
tps_demo: true,
|
||||
};
|
||||
let carlos_result = drone.send_airdrop(carlos_req).expect("send airdrop test");
|
||||
assert!(carlos_result > 0);
|
||||
|
|
Loading…
Reference in New Issue