* fixup! * fixups! * send the vote and count it * actually vote * test * Spelling fixes * Process the voting transaction in the leader's bank * Send tokens to the leader * Give leader tokens in more cases * Test for write_stage::leader_vote * Request airdrop inside fullnode and not the script * Change readme to indicate that drone should be up before leader And start drone before leader in snap scripts * Rename _kp => _keypair for keypairs and other review fixups * Remove empty else * tweak test_leader_vote numbers to be closer to testing 2/3 boundary * combine creating blob and transaction for leader/validator
23 lines
638 B
Rust
23 lines
638 B
Rust
use bincode::serialize;
|
|
use drone::DroneRequest;
|
|
use signature::PublicKey;
|
|
use std::error;
|
|
use std::io::Write;
|
|
use std::net::{SocketAddr, TcpStream};
|
|
|
|
pub fn request_airdrop(
|
|
drone_addr: &SocketAddr,
|
|
id: &PublicKey,
|
|
tokens: u64,
|
|
) -> Result<(), Box<error::Error>> {
|
|
let mut stream = TcpStream::connect(drone_addr)?;
|
|
let req = DroneRequest::GetAirdrop {
|
|
airdrop_request_amount: tokens,
|
|
client_public_key: *id,
|
|
};
|
|
let tx = serialize(&req).expect("serialize drone request");
|
|
stream.write_all(&tx).unwrap();
|
|
// TODO: add timeout to this function, in case of unresponsive drone
|
|
Ok(())
|
|
}
|