Better error handling messages for airdrops
This commit is contained in:
parent
501deeef56
commit
9a9f89293a
|
@ -291,7 +291,12 @@ fn airdrop_tokens(client: &mut ThinClient, leader: &NodeInfo, id: &Keypair, tx_c
|
||||||
id.pubkey(),
|
id.pubkey(),
|
||||||
);
|
);
|
||||||
|
|
||||||
request_airdrop(&drone_addr, &id.pubkey(), airdrop_amount as u64).unwrap();
|
if let Err(e) = request_airdrop(&drone_addr, &id.pubkey(), airdrop_amount as u64) {
|
||||||
|
panic!(
|
||||||
|
"Error requesting airdrop: {:?} to addr: {:?} amount: {}",
|
||||||
|
e, drone_addr, airdrop_amount
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: return airdrop Result from Drone instead of polling the
|
// TODO: return airdrop Result from Drone instead of polling the
|
||||||
// network
|
// network
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use bincode::{deserialize, serialize};
|
use bincode::{deserialize, serialize};
|
||||||
use drone::DroneRequest;
|
use drone::DroneRequest;
|
||||||
use signature::{Pubkey, Signature};
|
use signature::{Pubkey, Signature};
|
||||||
use std::error;
|
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::io::{Error, ErrorKind, Write};
|
use std::io::{Error, ErrorKind, Write};
|
||||||
use std::mem::size_of;
|
use std::mem::size_of;
|
||||||
|
@ -11,7 +10,7 @@ pub fn request_airdrop(
|
||||||
drone_addr: &SocketAddr,
|
drone_addr: &SocketAddr,
|
||||||
id: &Pubkey,
|
id: &Pubkey,
|
||||||
tokens: u64,
|
tokens: u64,
|
||||||
) -> Result<Signature, Box<error::Error>> {
|
) -> Result<Signature, Error> {
|
||||||
// TODO: make this async tokio client
|
// TODO: make this async tokio client
|
||||||
let mut stream = TcpStream::connect(drone_addr)?;
|
let mut stream = TcpStream::connect(drone_addr)?;
|
||||||
let req = DroneRequest::GetAirdrop {
|
let req = DroneRequest::GetAirdrop {
|
||||||
|
@ -19,7 +18,7 @@ pub fn request_airdrop(
|
||||||
client_pubkey: *id,
|
client_pubkey: *id,
|
||||||
};
|
};
|
||||||
let tx = serialize(&req).expect("serialize drone request");
|
let tx = serialize(&req).expect("serialize drone request");
|
||||||
stream.write_all(&tx).unwrap();
|
stream.write_all(&tx)?;
|
||||||
let mut buffer = [0; size_of::<Signature>()];
|
let mut buffer = [0; size_of::<Signature>()];
|
||||||
stream
|
stream
|
||||||
.read_exact(&mut buffer)
|
.read_exact(&mut buffer)
|
||||||
|
|
Loading…
Reference in New Issue