2018-05-08 17:32:50 -06:00
|
|
|
//! The `thin_client` module is a client-side object that interfaces with
|
|
|
|
//! a server-side TPU. Client code should use this object instead of writing
|
|
|
|
//! messages to the network directly. The binary encoding of its messages are
|
|
|
|
//! unstable and may change in future releases.
|
2018-02-28 14:16:50 -07:00
|
|
|
|
2019-03-06 17:08:40 -08:00
|
|
|
use crate::cluster_info::{ClusterInfoError, NodeInfo};
|
2019-01-31 20:41:03 -08:00
|
|
|
use crate::fullnode::{Fullnode, FullnodeConfig};
|
2019-03-06 17:08:40 -08:00
|
|
|
use crate::gossip_service::make_spy_node;
|
2018-12-07 20:16:27 -07:00
|
|
|
use crate::packet::PACKET_DATA_SIZE;
|
|
|
|
use crate::result::{Error, Result};
|
2019-01-14 00:10:03 -07:00
|
|
|
use crate::rpc_request::{RpcClient, RpcRequest, RpcRequestHandler};
|
2019-03-04 18:53:03 -08:00
|
|
|
use crate::service::Service;
|
2019-01-24 21:14:15 -08:00
|
|
|
use bincode::serialize_into;
|
2018-11-05 10:50:58 -07:00
|
|
|
use bs58;
|
|
|
|
use serde_json;
|
2018-11-16 08:45:59 -08:00
|
|
|
use solana_metrics;
|
|
|
|
use solana_metrics::influxdb;
|
2018-10-25 11:13:08 -07:00
|
|
|
use solana_sdk::account::Account;
|
2018-11-16 08:04:46 -08:00
|
|
|
use solana_sdk::hash::Hash;
|
2018-10-25 11:13:08 -07:00
|
|
|
use solana_sdk::pubkey::Pubkey;
|
2019-02-05 08:03:52 -08:00
|
|
|
use solana_sdk::signature::{Keypair, KeypairUtil, Signature};
|
2018-12-04 20:19:48 -08:00
|
|
|
use solana_sdk::system_transaction::SystemTransaction;
|
2018-11-16 08:45:59 -08:00
|
|
|
use solana_sdk::timing;
|
2018-11-29 16:18:47 -08:00
|
|
|
use solana_sdk::transaction::Transaction;
|
2018-09-09 04:50:43 +09:00
|
|
|
use std;
|
2018-03-28 20:13:10 -06:00
|
|
|
use std::io;
|
2018-04-28 00:31:20 -07:00
|
|
|
use std::net::{SocketAddr, UdpSocket};
|
2019-03-04 18:53:03 -08:00
|
|
|
use std::sync::atomic::{AtomicBool, Ordering};
|
2019-03-06 17:08:40 -08:00
|
|
|
use std::sync::Arc;
|
2018-07-20 18:13:47 -04:00
|
|
|
use std::thread::sleep;
|
|
|
|
use std::time::Duration;
|
2018-07-05 21:40:09 -07:00
|
|
|
use std::time::Instant;
|
2018-02-28 14:16:50 -07:00
|
|
|
|
2018-06-07 14:51:29 -06:00
|
|
|
/// An object for querying and sending transactions to the network.
|
2018-05-08 17:32:50 -06:00
|
|
|
pub struct ThinClient {
|
2018-11-05 10:50:58 -07:00
|
|
|
rpc_addr: SocketAddr,
|
2018-05-25 15:51:41 -06:00
|
|
|
transactions_addr: SocketAddr,
|
|
|
|
transactions_socket: UdpSocket,
|
2018-11-27 21:08:14 -08:00
|
|
|
rpc_client: RpcClient,
|
2018-02-28 14:16:50 -07:00
|
|
|
}
|
|
|
|
|
2018-05-08 17:32:50 -06:00
|
|
|
impl ThinClient {
|
2018-11-05 10:50:58 -07:00
|
|
|
/// Create a new ThinClient that will interface with the Rpc at `rpc_addr` using TCP
|
|
|
|
/// and the Tpu at `transactions_addr` over `transactions_socket` using UDP.
|
2018-05-22 09:46:52 -07:00
|
|
|
pub fn new(
|
2018-11-05 10:50:58 -07:00
|
|
|
rpc_addr: SocketAddr,
|
2018-05-25 15:51:41 -06:00
|
|
|
transactions_addr: SocketAddr,
|
|
|
|
transactions_socket: UdpSocket,
|
2018-11-29 13:28:52 -08:00
|
|
|
) -> Self {
|
|
|
|
Self::new_from_client(
|
|
|
|
rpc_addr,
|
|
|
|
transactions_addr,
|
|
|
|
transactions_socket,
|
2018-12-03 15:24:54 -08:00
|
|
|
RpcClient::new_from_socket(rpc_addr),
|
2018-11-29 13:28:52 -08:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn new_with_timeout(
|
|
|
|
rpc_addr: SocketAddr,
|
|
|
|
transactions_addr: SocketAddr,
|
|
|
|
transactions_socket: UdpSocket,
|
|
|
|
timeout: Duration,
|
|
|
|
) -> Self {
|
2018-12-03 15:24:54 -08:00
|
|
|
let rpc_client = RpcClient::new_with_timeout(rpc_addr, timeout);
|
2018-11-29 13:28:52 -08:00
|
|
|
Self::new_from_client(rpc_addr, transactions_addr, transactions_socket, rpc_client)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn new_from_client(
|
|
|
|
rpc_addr: SocketAddr,
|
|
|
|
transactions_addr: SocketAddr,
|
|
|
|
transactions_socket: UdpSocket,
|
|
|
|
rpc_client: RpcClient,
|
2018-05-22 09:46:52 -07:00
|
|
|
) -> Self {
|
2018-07-11 14:40:46 -06:00
|
|
|
ThinClient {
|
2018-11-29 13:28:52 -08:00
|
|
|
rpc_client,
|
2018-11-05 10:50:58 -07:00
|
|
|
rpc_addr,
|
2018-05-25 15:51:41 -06:00
|
|
|
transactions_addr,
|
|
|
|
transactions_socket,
|
2018-07-11 14:40:46 -06:00
|
|
|
}
|
2018-04-17 18:14:53 -04:00
|
|
|
}
|
|
|
|
|
2018-03-29 12:20:54 -06:00
|
|
|
/// Send a signed Transaction to the server for processing. This method
|
|
|
|
/// does not wait for a response.
|
2019-02-07 19:23:12 -08:00
|
|
|
pub fn transfer_signed(&self, transaction: &Transaction) -> io::Result<Signature> {
|
|
|
|
let mut buf = vec![0; transaction.serialized_size().unwrap() as usize];
|
2019-01-24 21:14:15 -08:00
|
|
|
let mut wr = std::io::Cursor::new(&mut buf[..]);
|
2019-02-07 19:23:12 -08:00
|
|
|
serialize_into(&mut wr, &transaction)
|
|
|
|
.expect("serialize Transaction in pub fn transfer_signed");
|
2019-01-24 21:14:15 -08:00
|
|
|
assert!(buf.len() < PACKET_DATA_SIZE);
|
2018-05-25 15:51:41 -06:00
|
|
|
self.transactions_socket
|
2019-01-24 21:14:15 -08:00
|
|
|
.send_to(&buf[..], &self.transactions_addr)?;
|
2019-02-07 19:23:12 -08:00
|
|
|
Ok(transaction.signatures[0])
|
2018-02-28 14:16:50 -07:00
|
|
|
}
|
|
|
|
|
2018-08-26 15:58:22 -07:00
|
|
|
/// Retry a sending a signed Transaction to the server for processing.
|
2018-11-06 06:07:43 -07:00
|
|
|
pub fn retry_transfer(
|
2018-08-26 15:58:22 -07:00
|
|
|
&mut self,
|
2018-11-06 06:07:43 -07:00
|
|
|
keypair: &Keypair,
|
2019-02-07 19:23:12 -08:00
|
|
|
transaction: &mut Transaction,
|
2018-08-26 15:58:22 -07:00
|
|
|
tries: usize,
|
|
|
|
) -> io::Result<Signature> {
|
|
|
|
for x in 0..tries {
|
2019-03-02 10:25:16 -08:00
|
|
|
transaction.sign(&[keypair], self.get_recent_blockhash());
|
2019-02-07 19:23:12 -08:00
|
|
|
let mut buf = vec![0; transaction.serialized_size().unwrap() as usize];
|
2019-01-24 21:14:15 -08:00
|
|
|
let mut wr = std::io::Cursor::new(&mut buf[..]);
|
2019-02-07 19:23:12 -08:00
|
|
|
serialize_into(&mut wr, &transaction)
|
|
|
|
.expect("serialize Transaction in pub fn transfer_signed");
|
2018-08-26 15:58:22 -07:00
|
|
|
self.transactions_socket
|
2019-01-24 21:14:15 -08:00
|
|
|
.send_to(&buf[..], &self.transactions_addr)?;
|
2019-02-07 19:23:12 -08:00
|
|
|
if self.poll_for_signature(&transaction.signatures[0]).is_ok() {
|
|
|
|
return Ok(transaction.signatures[0]);
|
2018-08-26 15:58:22 -07:00
|
|
|
}
|
|
|
|
info!("{} tries failed transfer to {}", x, self.transactions_addr);
|
|
|
|
}
|
|
|
|
Err(io::Error::new(
|
|
|
|
io::ErrorKind::Other,
|
2018-11-06 06:07:43 -07:00
|
|
|
"retry_transfer failed",
|
2018-08-26 15:58:22 -07:00
|
|
|
))
|
|
|
|
}
|
|
|
|
|
2018-03-29 12:20:54 -06:00
|
|
|
/// Creates, signs, and processes a Transaction. Useful for writing unit-tests.
|
2018-02-28 14:16:50 -07:00
|
|
|
pub fn transfer(
|
2018-03-05 11:11:00 -07:00
|
|
|
&self,
|
2019-03-05 16:28:14 -08:00
|
|
|
lamports: u64,
|
2018-08-09 08:56:04 -06:00
|
|
|
keypair: &Keypair,
|
2018-08-09 09:13:57 -06:00
|
|
|
to: Pubkey,
|
2019-03-02 10:25:16 -08:00
|
|
|
blockhash: &Hash,
|
2018-03-01 12:23:27 -07:00
|
|
|
) -> io::Result<Signature> {
|
2019-02-05 08:03:52 -08:00
|
|
|
debug!(
|
2019-03-05 16:28:14 -08:00
|
|
|
"transfer: lamports={} from={:?} to={:?} blockhash={:?}",
|
|
|
|
lamports,
|
2019-02-05 08:03:52 -08:00
|
|
|
keypair.pubkey(),
|
|
|
|
to,
|
2019-03-02 10:25:16 -08:00
|
|
|
blockhash
|
2019-02-05 08:03:52 -08:00
|
|
|
);
|
2018-07-05 21:40:09 -07:00
|
|
|
let now = Instant::now();
|
2019-03-05 16:28:14 -08:00
|
|
|
let transaction = SystemTransaction::new_account(keypair, to, lamports, *blockhash, 0);
|
2019-02-07 19:23:12 -08:00
|
|
|
let result = self.transfer_signed(&transaction);
|
2018-11-16 08:45:59 -08:00
|
|
|
solana_metrics::submit(
|
2018-07-05 21:40:09 -07:00
|
|
|
influxdb::Point::new("thinclient")
|
|
|
|
.add_tag("op", influxdb::Value::String("transfer".to_string()))
|
|
|
|
.add_field(
|
|
|
|
"duration_ms",
|
|
|
|
influxdb::Value::Integer(timing::duration_as_ms(&now.elapsed()) as i64),
|
2018-12-07 20:01:28 -07:00
|
|
|
)
|
|
|
|
.to_owned(),
|
2018-07-05 21:40:09 -07:00
|
|
|
);
|
|
|
|
result
|
2018-02-28 14:16:50 -07:00
|
|
|
}
|
|
|
|
|
2018-10-25 16:58:40 -07:00
|
|
|
pub fn get_account_userdata(&mut self, pubkey: &Pubkey) -> io::Result<Option<Vec<u8>>> {
|
2018-11-14 18:57:34 -08:00
|
|
|
let params = json!([format!("{}", pubkey)]);
|
2019-02-07 19:23:12 -08:00
|
|
|
let response =
|
|
|
|
self.rpc_client
|
|
|
|
.make_rpc_request(1, RpcRequest::GetAccountInfo, Some(params));
|
|
|
|
match response {
|
|
|
|
Ok(account_json) => {
|
|
|
|
let account: Account =
|
|
|
|
serde_json::from_value(account_json).expect("deserialize account");
|
|
|
|
Ok(Some(account.userdata))
|
|
|
|
}
|
|
|
|
Err(error) => {
|
|
|
|
debug!("get_account_userdata failed: {:?}", error);
|
|
|
|
Err(io::Error::new(
|
|
|
|
io::ErrorKind::Other,
|
|
|
|
"get_account_userdata failed",
|
|
|
|
))
|
|
|
|
}
|
2018-10-25 16:58:40 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-29 12:20:54 -06:00
|
|
|
/// Request the balance of the user holding `pubkey`. This method blocks
|
|
|
|
/// until the server sends a response. If the response packet is dropped
|
|
|
|
/// by the network, this method will hang indefinitely.
|
2018-11-05 09:36:22 -07:00
|
|
|
pub fn get_balance(&mut self, pubkey: &Pubkey) -> io::Result<u64> {
|
2018-11-05 10:50:58 -07:00
|
|
|
trace!("get_balance sending request to {}", self.rpc_addr);
|
2018-11-14 18:57:34 -08:00
|
|
|
let params = json!([format!("{}", pubkey)]);
|
2019-02-07 19:23:12 -08:00
|
|
|
let response =
|
|
|
|
self.rpc_client
|
|
|
|
.make_rpc_request(1, RpcRequest::GetAccountInfo, Some(params));
|
|
|
|
|
|
|
|
response
|
|
|
|
.and_then(|account_json| {
|
|
|
|
let account: Account =
|
|
|
|
serde_json::from_value(account_json).expect("deserialize account");
|
|
|
|
trace!("Response account {:?} {:?}", pubkey, account);
|
2019-03-05 16:28:14 -08:00
|
|
|
trace!("get_balance {:?}", account.lamports);
|
|
|
|
Ok(account.lamports)
|
2019-02-07 19:23:12 -08:00
|
|
|
})
|
|
|
|
.map_err(|error| {
|
|
|
|
debug!("Response account {}: None (error: {:?})", pubkey, error);
|
|
|
|
io::Error::new(io::ErrorKind::Other, "AccountNotFound")
|
|
|
|
})
|
2018-03-01 12:23:27 -07:00
|
|
|
}
|
|
|
|
|
2018-05-14 07:16:39 -06:00
|
|
|
/// Request the transaction count. If the response packet is dropped by the network,
|
2018-08-23 20:57:13 -07:00
|
|
|
/// this method will try again 5 times.
|
2018-05-14 09:45:09 -06:00
|
|
|
pub fn transaction_count(&mut self) -> u64 {
|
2018-07-22 16:20:07 -07:00
|
|
|
debug!("transaction_count");
|
2019-02-07 19:23:12 -08:00
|
|
|
for _tries in 0..5 {
|
|
|
|
let response =
|
|
|
|
self.rpc_client
|
|
|
|
.make_rpc_request(1, RpcRequest::GetTransactionCount, None);
|
|
|
|
|
|
|
|
match response {
|
|
|
|
Ok(value) => {
|
|
|
|
debug!("transaction_count response: {:?}", value);
|
|
|
|
let transaction_count = value.as_u64().unwrap();
|
|
|
|
return transaction_count;
|
|
|
|
}
|
|
|
|
Err(error) => {
|
|
|
|
debug!("transaction_count failed: {:?}", error);
|
|
|
|
}
|
|
|
|
};
|
2018-05-14 07:16:39 -06:00
|
|
|
}
|
2019-02-07 19:23:12 -08:00
|
|
|
0
|
2018-05-14 07:16:39 -06:00
|
|
|
}
|
|
|
|
|
2019-02-12 15:03:11 -08:00
|
|
|
/// Request the last Entry ID from the server without blocking.
|
2019-03-02 10:25:16 -08:00
|
|
|
/// Returns the blockhash Hash or None if there was no response from the server.
|
|
|
|
pub fn try_get_recent_blockhash(&mut self, mut num_retries: u64) -> Option<Hash> {
|
2019-02-07 15:08:41 -08:00
|
|
|
loop {
|
2019-03-02 10:25:16 -08:00
|
|
|
trace!("try_get_recent_blockhash send_to {}", &self.rpc_addr);
|
2019-03-02 10:20:10 -08:00
|
|
|
let response =
|
|
|
|
self.rpc_client
|
2019-03-02 10:25:16 -08:00
|
|
|
.make_rpc_request(1, RpcRequest::GetRecentBlockhash, None);
|
2018-11-05 10:50:58 -07:00
|
|
|
|
2019-02-07 19:23:12 -08:00
|
|
|
match response {
|
|
|
|
Ok(value) => {
|
2019-03-02 10:25:16 -08:00
|
|
|
let blockhash_str = value.as_str().unwrap();
|
|
|
|
let blockhash_vec = bs58::decode(blockhash_str).into_vec().unwrap();
|
|
|
|
return Some(Hash::new(&blockhash_vec));
|
2019-02-07 19:23:12 -08:00
|
|
|
}
|
|
|
|
Err(error) => {
|
2019-03-02 10:25:16 -08:00
|
|
|
debug!("thin_client get_recent_blockhash error: {:?}", error);
|
2019-02-12 15:03:11 -08:00
|
|
|
num_retries -= 1;
|
|
|
|
if num_retries == 0 {
|
|
|
|
return None;
|
|
|
|
}
|
2019-02-07 19:23:12 -08:00
|
|
|
}
|
2019-02-12 15:03:11 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Request the last Entry ID from the server. This method blocks
|
|
|
|
/// until the server sends a response.
|
2019-03-02 10:25:16 -08:00
|
|
|
pub fn get_recent_blockhash(&mut self) -> Hash {
|
2019-02-12 15:03:11 -08:00
|
|
|
loop {
|
2019-03-02 10:25:16 -08:00
|
|
|
trace!("get_recent_blockhash send_to {}", &self.rpc_addr);
|
|
|
|
if let Some(hash) = self.try_get_recent_blockhash(10) {
|
2019-02-12 15:03:11 -08:00
|
|
|
return hash;
|
|
|
|
}
|
2018-05-14 09:40:29 -06:00
|
|
|
}
|
2018-03-05 12:48:09 -07:00
|
|
|
}
|
2018-02-28 14:16:50 -07:00
|
|
|
|
2019-02-07 15:07:10 -08:00
|
|
|
/// Request a new last Entry ID from the server. This method blocks
|
|
|
|
/// until the server sends a response.
|
2019-03-02 10:25:16 -08:00
|
|
|
pub fn get_next_blockhash(&mut self, previous_blockhash: &Hash) -> Hash {
|
|
|
|
self.get_next_blockhash_ext(previous_blockhash, &|| {
|
2019-02-26 10:48:18 -08:00
|
|
|
sleep(Duration::from_millis(100));
|
|
|
|
})
|
|
|
|
}
|
2019-03-02 10:25:16 -08:00
|
|
|
pub fn get_next_blockhash_ext(&mut self, previous_blockhash: &Hash, func: &Fn()) -> Hash {
|
2019-02-07 15:07:10 -08:00
|
|
|
loop {
|
2019-03-02 10:25:16 -08:00
|
|
|
let blockhash = self.get_recent_blockhash();
|
|
|
|
if blockhash != *previous_blockhash {
|
|
|
|
break blockhash;
|
2019-02-07 15:07:10 -08:00
|
|
|
}
|
2019-03-02 10:25:16 -08:00
|
|
|
debug!("Got same blockhash ({:?}), will retry...", blockhash);
|
2019-02-26 10:48:18 -08:00
|
|
|
func()
|
2019-02-07 15:07:10 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-25 18:24:25 -07:00
|
|
|
pub fn submit_poll_balance_metrics(elapsed: &Duration) {
|
2018-11-16 08:45:59 -08:00
|
|
|
solana_metrics::submit(
|
2018-07-05 21:40:09 -07:00
|
|
|
influxdb::Point::new("thinclient")
|
|
|
|
.add_tag("op", influxdb::Value::String("get_balance".to_string()))
|
|
|
|
.add_field(
|
|
|
|
"duration_ms",
|
2018-08-25 18:24:25 -07:00
|
|
|
influxdb::Value::Integer(timing::duration_as_ms(elapsed) as i64),
|
2018-12-07 20:01:28 -07:00
|
|
|
)
|
|
|
|
.to_owned(),
|
2018-07-05 21:40:09 -07:00
|
|
|
);
|
2018-08-25 18:24:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn poll_balance_with_timeout(
|
|
|
|
&mut self,
|
|
|
|
pubkey: &Pubkey,
|
|
|
|
polling_frequency: &Duration,
|
|
|
|
timeout: &Duration,
|
2018-11-05 09:36:22 -07:00
|
|
|
) -> io::Result<u64> {
|
2018-08-25 18:24:25 -07:00
|
|
|
let now = Instant::now();
|
|
|
|
loop {
|
2018-09-04 21:33:19 -07:00
|
|
|
match self.get_balance(&pubkey) {
|
|
|
|
Ok(bal) => {
|
|
|
|
ThinClient::submit_poll_balance_metrics(&now.elapsed());
|
|
|
|
return Ok(bal);
|
|
|
|
}
|
2018-08-25 18:24:25 -07:00
|
|
|
Err(e) => {
|
|
|
|
sleep(*polling_frequency);
|
|
|
|
if now.elapsed() > *timeout {
|
|
|
|
ThinClient::submit_poll_balance_metrics(&now.elapsed());
|
|
|
|
return Err(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2018-07-26 21:27:44 -07:00
|
|
|
}
|
2018-05-25 21:54:20 -06:00
|
|
|
}
|
2018-06-28 12:58:33 -06:00
|
|
|
|
2018-11-05 09:36:22 -07:00
|
|
|
pub fn poll_get_balance(&mut self, pubkey: &Pubkey) -> io::Result<u64> {
|
2018-08-25 18:24:25 -07:00
|
|
|
self.poll_balance_with_timeout(pubkey, &Duration::from_millis(100), &Duration::from_secs(1))
|
|
|
|
}
|
|
|
|
|
2018-07-20 19:05:39 -04:00
|
|
|
/// Poll the server to confirm a transaction.
|
2018-08-09 09:26:21 -06:00
|
|
|
pub fn poll_for_signature(&mut self, signature: &Signature) -> io::Result<()> {
|
2018-07-20 19:05:39 -04:00
|
|
|
let now = Instant::now();
|
2018-08-09 09:26:21 -06:00
|
|
|
while !self.check_signature(signature) {
|
2019-02-14 17:55:47 -08:00
|
|
|
if now.elapsed().as_secs() > 15 {
|
2018-07-20 19:05:39 -04:00
|
|
|
// TODO: Return a better error.
|
|
|
|
return Err(io::Error::new(io::ErrorKind::Other, "signature not found"));
|
|
|
|
}
|
2019-02-14 17:55:47 -08:00
|
|
|
sleep(Duration::from_millis(250));
|
2018-07-20 19:05:39 -04:00
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2018-06-28 12:58:33 -06:00
|
|
|
/// Check a signature in the bank. This method blocks
|
|
|
|
/// until the server sends a response.
|
2018-08-09 09:26:21 -06:00
|
|
|
pub fn check_signature(&mut self, signature: &Signature) -> bool {
|
2019-02-07 19:23:12 -08:00
|
|
|
trace!("check_signature: {:?}", signature);
|
2018-11-14 18:57:34 -08:00
|
|
|
let params = json!([format!("{}", signature)]);
|
2018-07-05 21:40:09 -07:00
|
|
|
let now = Instant::now();
|
2019-02-07 19:23:12 -08:00
|
|
|
|
|
|
|
loop {
|
|
|
|
let response = self.rpc_client.make_rpc_request(
|
2018-11-05 10:50:58 -07:00
|
|
|
1,
|
2019-01-14 00:10:03 -07:00
|
|
|
RpcRequest::ConfirmTransaction,
|
2018-11-05 10:50:58 -07:00
|
|
|
Some(params.clone()),
|
|
|
|
);
|
|
|
|
|
2019-02-07 19:23:12 -08:00
|
|
|
match response {
|
|
|
|
Ok(confirmation) => {
|
|
|
|
let signature_status = confirmation.as_bool().unwrap();
|
|
|
|
if signature_status {
|
|
|
|
trace!("Response found signature");
|
|
|
|
} else {
|
|
|
|
trace!("Response signature not found");
|
|
|
|
}
|
|
|
|
solana_metrics::submit(
|
|
|
|
influxdb::Point::new("thinclient")
|
|
|
|
.add_tag("op", influxdb::Value::String("check_signature".to_string()))
|
|
|
|
.add_field(
|
|
|
|
"duration_ms",
|
|
|
|
influxdb::Value::Integer(
|
|
|
|
timing::duration_as_ms(&now.elapsed()) as i64
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.to_owned(),
|
|
|
|
);
|
|
|
|
return signature_status;
|
2018-06-28 12:58:33 -06:00
|
|
|
}
|
2019-02-07 19:23:12 -08:00
|
|
|
Err(err) => {
|
|
|
|
debug!("check_signature request failed: {:?}", err);
|
|
|
|
}
|
|
|
|
};
|
2018-06-28 12:58:33 -06:00
|
|
|
}
|
|
|
|
}
|
2019-03-03 22:01:09 -08:00
|
|
|
pub fn fullnode_exit(&mut self) -> io::Result<bool> {
|
|
|
|
trace!("fullnode_exit sending request to {}", self.rpc_addr);
|
|
|
|
let response = self
|
|
|
|
.rpc_client
|
|
|
|
.make_rpc_request(1, RpcRequest::FullnodeExit, None)
|
|
|
|
.map_err(|error| {
|
|
|
|
debug!("Response from {} fullndoe_exit: {}", self.rpc_addr, error);
|
|
|
|
io::Error::new(io::ErrorKind::Other, "FullodeExit request failure")
|
|
|
|
})?;
|
|
|
|
serde_json::from_value(response).map_err(|error| {
|
|
|
|
debug!(
|
|
|
|
"ParseError: from {} fullndoe_exit: {}",
|
|
|
|
self.rpc_addr, error
|
|
|
|
);
|
|
|
|
io::Error::new(io::ErrorKind::Other, "FullodeExit parse failure")
|
|
|
|
})
|
|
|
|
}
|
2018-05-22 09:46:52 -07:00
|
|
|
}
|
|
|
|
|
2018-07-05 21:40:09 -07:00
|
|
|
impl Drop for ThinClient {
|
|
|
|
fn drop(&mut self) {
|
2018-11-16 08:45:59 -08:00
|
|
|
solana_metrics::flush();
|
2018-07-05 21:40:09 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-06 18:53:59 -08:00
|
|
|
pub fn poll_gossip_for_leader(gossip_addr: SocketAddr, timeout: Duration) -> Result<NodeInfo> {
|
2018-08-20 14:03:36 -06:00
|
|
|
let exit = Arc::new(AtomicBool::new(false));
|
2019-03-06 15:41:21 -08:00
|
|
|
let entry_point = NodeInfo::new_entry_point(&gossip_addr);
|
2019-03-06 17:08:40 -08:00
|
|
|
let (gossip_service, cluster_info) = make_spy_node(&entry_point, &exit);
|
2018-08-20 14:03:36 -06:00
|
|
|
|
|
|
|
let now = Instant::now();
|
2019-03-06 15:41:21 -08:00
|
|
|
let result = loop {
|
|
|
|
sleep(Duration::from_millis(100));
|
2019-03-06 17:08:40 -08:00
|
|
|
trace!("polling {:?} for leader", gossip_addr);
|
2018-09-09 04:50:43 +09:00
|
|
|
|
2019-03-06 15:41:21 -08:00
|
|
|
if let Some(leader) = cluster_info.read().unwrap().get_gossip_top_leader() {
|
|
|
|
if log_enabled!(log::Level::Trace) {
|
|
|
|
trace!("{}", cluster_info.read().unwrap().node_info_trace());
|
|
|
|
}
|
|
|
|
break Ok(leader.clone());
|
2018-09-09 04:50:43 +09:00
|
|
|
}
|
|
|
|
|
2019-02-27 20:57:01 -08:00
|
|
|
if log_enabled!(log::Level::Trace) {
|
2018-10-08 20:55:54 -06:00
|
|
|
trace!("{}", cluster_info.read().unwrap().node_info_trace());
|
2018-09-09 04:50:43 +09:00
|
|
|
}
|
|
|
|
|
2019-03-06 18:53:59 -08:00
|
|
|
if now.elapsed() > timeout {
|
2019-03-06 15:41:21 -08:00
|
|
|
break Err(Error::ClusterInfoError(ClusterInfoError::NoLeader));
|
2018-08-20 14:03:36 -06:00
|
|
|
}
|
2019-03-06 15:41:21 -08:00
|
|
|
};
|
2018-08-20 14:03:36 -06:00
|
|
|
|
2019-03-04 18:53:03 -08:00
|
|
|
exit.store(true, Ordering::Relaxed);
|
|
|
|
gossip_service.join()?;
|
2018-09-09 04:50:43 +09:00
|
|
|
|
2019-03-06 15:41:21 -08:00
|
|
|
result
|
2018-08-20 14:03:36 -06:00
|
|
|
}
|
|
|
|
|
2018-10-31 17:47:50 -07:00
|
|
|
pub fn retry_get_balance(
|
|
|
|
client: &mut ThinClient,
|
|
|
|
bob_pubkey: &Pubkey,
|
2018-11-05 09:36:22 -07:00
|
|
|
expected_balance: Option<u64>,
|
|
|
|
) -> Option<u64> {
|
2018-10-31 17:47:50 -07:00
|
|
|
const LAST: usize = 30;
|
|
|
|
for run in 0..LAST {
|
|
|
|
let balance_result = client.poll_get_balance(bob_pubkey);
|
|
|
|
if expected_balance.is_none() {
|
|
|
|
return balance_result.ok();
|
|
|
|
}
|
|
|
|
trace!(
|
|
|
|
"retry_get_balance[{}] {:?} {:?}",
|
|
|
|
run,
|
|
|
|
balance_result,
|
|
|
|
expected_balance
|
|
|
|
);
|
|
|
|
if let (Some(expected_balance), Ok(balance_result)) = (expected_balance, balance_result) {
|
|
|
|
if expected_balance == balance_result {
|
|
|
|
return Some(balance_result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
None
|
|
|
|
}
|
|
|
|
|
2019-02-26 19:26:42 -08:00
|
|
|
pub fn new_fullnode() -> (Fullnode, NodeInfo, Keypair, String) {
|
2019-02-26 16:35:00 -08:00
|
|
|
use crate::blocktree::create_new_tmp_ledger;
|
2018-12-07 20:16:27 -07:00
|
|
|
use crate::cluster_info::Node;
|
2019-02-05 08:03:52 -08:00
|
|
|
use crate::fullnode::Fullnode;
|
2019-02-22 22:55:46 -07:00
|
|
|
use solana_sdk::genesis_block::GenesisBlock;
|
2019-01-28 10:53:29 -08:00
|
|
|
use solana_sdk::signature::KeypairUtil;
|
|
|
|
|
2019-01-29 18:12:32 -08:00
|
|
|
let node_keypair = Arc::new(Keypair::new());
|
|
|
|
let node = Node::new_localhost_with_pubkey(node_keypair.pubkey());
|
|
|
|
let node_info = node.info.clone();
|
2019-01-28 10:53:29 -08:00
|
|
|
|
2019-02-22 22:55:46 -07:00
|
|
|
let (genesis_block, mint_keypair) = GenesisBlock::new_with_leader(10_000, node_info.id, 42);
|
2019-03-02 10:25:16 -08:00
|
|
|
let (ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
|
2019-01-28 10:53:29 -08:00
|
|
|
|
2019-03-05 08:52:53 -07:00
|
|
|
let voting_keypair = Keypair::new();
|
2019-01-29 18:12:32 -08:00
|
|
|
let node = Fullnode::new(
|
|
|
|
node,
|
2019-01-30 20:51:50 -07:00
|
|
|
&node_keypair,
|
2019-01-28 10:53:29 -08:00
|
|
|
&ledger_path,
|
2019-01-31 21:12:51 -07:00
|
|
|
voting_keypair,
|
2019-01-28 10:53:29 -08:00
|
|
|
None,
|
2019-01-31 20:41:03 -08:00
|
|
|
&FullnodeConfig::default(),
|
2019-01-28 10:53:29 -08:00
|
|
|
);
|
|
|
|
|
2019-01-29 18:12:32 -08:00
|
|
|
(node, node_info, mint_keypair, ledger_path)
|
2019-01-28 10:53:29 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
use crate::client::mk_client;
|
2019-01-24 21:14:15 -08:00
|
|
|
use bincode::{deserialize, serialize};
|
2018-11-16 08:04:46 -08:00
|
|
|
use solana_sdk::system_instruction::SystemInstruction;
|
2019-03-02 14:51:26 -07:00
|
|
|
use solana_vote_api::vote_state::VoteState;
|
|
|
|
use solana_vote_api::vote_transaction::VoteTransaction;
|
2018-12-04 20:19:48 -08:00
|
|
|
use std::fs::remove_dir_all;
|
2018-02-28 14:16:50 -07:00
|
|
|
|
|
|
|
#[test]
|
2019-02-05 08:03:52 -08:00
|
|
|
fn test_thin_client_basic() {
|
2018-12-14 12:36:50 -08:00
|
|
|
solana_logger::setup();
|
2019-02-26 19:26:42 -08:00
|
|
|
let (server, leader_data, alice, ledger_path) = new_fullnode();
|
2018-08-09 08:56:04 -06:00
|
|
|
let bob_pubkey = Keypair::new().pubkey();
|
2019-01-28 10:53:29 -08:00
|
|
|
|
2019-02-05 08:03:52 -08:00
|
|
|
info!(
|
|
|
|
"found leader: {:?}",
|
2019-03-06 18:53:59 -08:00
|
|
|
poll_gossip_for_leader(leader_data.gossip, Duration::from_secs(5)).unwrap()
|
2019-02-05 08:03:52 -08:00
|
|
|
);
|
2018-02-28 14:16:50 -07:00
|
|
|
|
2019-01-28 10:53:29 -08:00
|
|
|
let mut client = mk_client(&leader_data);
|
2018-03-27 14:45:04 -06:00
|
|
|
|
2018-11-05 10:50:58 -07:00
|
|
|
let transaction_count = client.transaction_count();
|
|
|
|
assert_eq!(transaction_count, 0);
|
2019-02-05 08:03:52 -08:00
|
|
|
|
2019-03-02 10:25:16 -08:00
|
|
|
let blockhash = client.get_recent_blockhash();
|
|
|
|
info!("test_thin_client blockhash: {:?}", blockhash);
|
2019-02-05 08:03:52 -08:00
|
|
|
|
2019-03-02 10:20:10 -08:00
|
|
|
let signature = client
|
2019-03-02 10:25:16 -08:00
|
|
|
.transfer(500, &alice, bob_pubkey, &blockhash)
|
2019-03-02 10:20:10 -08:00
|
|
|
.unwrap();
|
2019-02-05 08:03:52 -08:00
|
|
|
info!("test_thin_client signature: {:?}", signature);
|
2018-08-09 09:26:21 -06:00
|
|
|
client.poll_for_signature(&signature).unwrap();
|
2019-02-05 08:03:52 -08:00
|
|
|
|
2018-07-20 19:05:39 -04:00
|
|
|
let balance = client.get_balance(&bob_pubkey);
|
2018-05-07 16:49:15 -07:00
|
|
|
assert_eq!(balance.unwrap(), 500);
|
2019-02-05 08:03:52 -08:00
|
|
|
|
2018-11-05 10:50:58 -07:00
|
|
|
let transaction_count = client.transaction_count();
|
|
|
|
assert_eq!(transaction_count, 1);
|
2019-03-03 16:44:06 -08:00
|
|
|
server.close().unwrap();
|
2018-08-06 12:35:38 -07:00
|
|
|
remove_dir_all(ledger_path).unwrap();
|
2018-02-28 14:16:50 -07:00
|
|
|
}
|
2018-05-04 11:11:39 -07:00
|
|
|
|
2018-05-09 13:33:33 -06:00
|
|
|
#[test]
|
2018-07-05 12:01:40 -07:00
|
|
|
#[ignore]
|
2018-05-09 13:33:33 -06:00
|
|
|
fn test_bad_sig() {
|
2018-12-14 12:36:50 -08:00
|
|
|
solana_logger::setup();
|
2019-02-26 19:26:42 -08:00
|
|
|
let (server, leader_data, alice, ledger_path) = new_fullnode();
|
2018-08-09 08:56:04 -06:00
|
|
|
let bob_pubkey = Keypair::new().pubkey();
|
2019-02-05 08:03:52 -08:00
|
|
|
info!(
|
|
|
|
"found leader: {:?}",
|
2019-03-06 18:53:59 -08:00
|
|
|
poll_gossip_for_leader(leader_data.gossip, Duration::from_secs(5)).unwrap()
|
2019-02-05 08:03:52 -08:00
|
|
|
);
|
2018-05-09 13:33:33 -06:00
|
|
|
|
2019-01-28 10:53:29 -08:00
|
|
|
let mut client = mk_client(&leader_data);
|
|
|
|
|
2019-03-02 10:25:16 -08:00
|
|
|
let blockhash = client.get_recent_blockhash();
|
2018-05-09 13:33:33 -06:00
|
|
|
|
2019-03-02 10:25:16 -08:00
|
|
|
let tx = SystemTransaction::new_account(&alice, bob_pubkey, 500, blockhash, 0);
|
2018-05-09 13:33:33 -06:00
|
|
|
|
2018-07-11 14:40:46 -06:00
|
|
|
let _sig = client.transfer_signed(&tx).unwrap();
|
2018-05-09 13:33:33 -06:00
|
|
|
|
2019-03-02 10:25:16 -08:00
|
|
|
let blockhash = client.get_recent_blockhash();
|
2018-05-09 13:33:33 -06:00
|
|
|
|
2019-03-02 10:25:16 -08:00
|
|
|
let mut tr2 = SystemTransaction::new_account(&alice, bob_pubkey, 501, blockhash, 0);
|
2018-09-28 16:16:35 -07:00
|
|
|
let mut instruction2 = deserialize(tr2.userdata(0)).unwrap();
|
2019-03-05 16:28:14 -08:00
|
|
|
if let SystemInstruction::Move { ref mut lamports } = instruction2 {
|
|
|
|
*lamports = 502;
|
2018-05-22 21:42:04 -06:00
|
|
|
}
|
2018-09-28 16:16:35 -07:00
|
|
|
tr2.instructions[0].userdata = serialize(&instruction2).unwrap();
|
2018-08-09 09:26:21 -06:00
|
|
|
let signature = client.transfer_signed(&tr2).unwrap();
|
|
|
|
client.poll_for_signature(&signature).unwrap();
|
2018-05-09 13:33:33 -06:00
|
|
|
|
2018-07-20 19:05:39 -04:00
|
|
|
let balance = client.get_balance(&bob_pubkey);
|
2019-02-05 08:03:52 -08:00
|
|
|
assert_eq!(balance.unwrap(), 1001);
|
2019-03-03 16:44:06 -08:00
|
|
|
server.close().unwrap();
|
2018-08-03 11:06:06 -07:00
|
|
|
remove_dir_all(ledger_path).unwrap();
|
2018-06-28 12:58:33 -06:00
|
|
|
}
|
2018-08-23 20:57:13 -07:00
|
|
|
|
2018-10-31 17:47:50 -07:00
|
|
|
#[test]
|
|
|
|
fn test_register_vote_account() {
|
2018-12-14 12:36:50 -08:00
|
|
|
solana_logger::setup();
|
2019-02-26 19:26:42 -08:00
|
|
|
let (server, leader_data, alice, ledger_path) = new_fullnode();
|
2019-02-05 08:03:52 -08:00
|
|
|
info!(
|
|
|
|
"found leader: {:?}",
|
2019-03-06 18:53:59 -08:00
|
|
|
poll_gossip_for_leader(leader_data.gossip, Duration::from_secs(5)).unwrap()
|
2019-02-05 08:03:52 -08:00
|
|
|
);
|
2018-10-31 17:47:50 -07:00
|
|
|
|
2019-01-28 10:53:29 -08:00
|
|
|
let mut client = mk_client(&leader_data);
|
2018-10-31 17:47:50 -07:00
|
|
|
|
2019-03-05 16:28:14 -08:00
|
|
|
// Create the validator account, transfer some lamports to that account
|
2018-10-31 17:47:50 -07:00
|
|
|
let validator_keypair = Keypair::new();
|
2019-03-02 10:25:16 -08:00
|
|
|
let blockhash = client.get_recent_blockhash();
|
2018-10-31 17:47:50 -07:00
|
|
|
let signature = client
|
2019-03-02 10:25:16 -08:00
|
|
|
.transfer(500, &alice, validator_keypair.pubkey(), &blockhash)
|
2018-10-31 17:47:50 -07:00
|
|
|
.unwrap();
|
|
|
|
|
2019-01-28 14:52:35 -08:00
|
|
|
client.poll_for_signature(&signature).unwrap();
|
2018-10-31 17:47:50 -07:00
|
|
|
|
2018-11-28 20:10:30 -08:00
|
|
|
// Create and register the vote account
|
2018-10-31 17:47:50 -07:00
|
|
|
let validator_vote_account_keypair = Keypair::new();
|
|
|
|
let vote_account_id = validator_vote_account_keypair.pubkey();
|
2019-03-02 10:25:16 -08:00
|
|
|
let blockhash = client.get_recent_blockhash();
|
2018-10-31 17:47:50 -07:00
|
|
|
|
2019-03-04 17:50:19 -08:00
|
|
|
let transaction =
|
|
|
|
VoteTransaction::new_account(&validator_keypair, vote_account_id, blockhash, 1, 1);
|
2018-11-15 17:05:31 -08:00
|
|
|
let signature = client.transfer_signed(&transaction).unwrap();
|
2019-01-28 14:52:35 -08:00
|
|
|
client.poll_for_signature(&signature).unwrap();
|
2018-11-15 17:05:31 -08:00
|
|
|
|
2018-10-31 17:47:50 -07:00
|
|
|
let balance = retry_get_balance(&mut client, &vote_account_id, Some(1))
|
|
|
|
.expect("Expected balance for new account to exist");
|
|
|
|
assert_eq!(balance, 1);
|
|
|
|
|
|
|
|
const LAST: usize = 30;
|
|
|
|
for run in 0..=LAST {
|
|
|
|
let account_user_data = client
|
|
|
|
.get_account_userdata(&vote_account_id)
|
|
|
|
.expect("Expected valid response for account userdata")
|
|
|
|
.expect("Expected valid account userdata to exist after account creation");
|
|
|
|
|
2019-02-01 15:50:11 -07:00
|
|
|
let vote_state = VoteState::deserialize(&account_user_data);
|
2018-10-31 17:47:50 -07:00
|
|
|
|
2019-03-05 10:53:10 -07:00
|
|
|
if vote_state.map(|vote_state| vote_state.delegate_id) == Ok(vote_account_id) {
|
2018-10-31 17:47:50 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if run == LAST {
|
|
|
|
panic!("Expected successful vote account registration");
|
|
|
|
}
|
|
|
|
sleep(Duration::from_millis(900));
|
|
|
|
}
|
|
|
|
|
2019-03-03 16:44:06 -08:00
|
|
|
server.close().unwrap();
|
2018-10-31 17:47:50 -07:00
|
|
|
remove_dir_all(ledger_path).unwrap();
|
|
|
|
}
|
|
|
|
|
2018-08-23 20:57:13 -07:00
|
|
|
#[test]
|
|
|
|
fn test_transaction_count() {
|
|
|
|
// set a bogus address, see that we don't hang
|
2018-12-14 12:36:50 -08:00
|
|
|
solana_logger::setup();
|
2018-08-23 20:57:13 -07:00
|
|
|
let addr = "0.0.0.0:1234".parse().unwrap();
|
|
|
|
let transactions_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
2018-11-29 13:28:52 -08:00
|
|
|
let mut client =
|
|
|
|
ThinClient::new_with_timeout(addr, addr, transactions_socket, Duration::from_secs(2));
|
2018-08-23 20:57:13 -07:00
|
|
|
assert_eq!(client.transaction_count(), 0);
|
|
|
|
}
|
2018-09-04 21:33:19 -07:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_zero_balance_after_nonzero() {
|
2018-12-14 12:36:50 -08:00
|
|
|
solana_logger::setup();
|
2019-02-26 19:26:42 -08:00
|
|
|
let (server, leader_data, alice, ledger_path) = new_fullnode();
|
2018-09-04 21:33:19 -07:00
|
|
|
let bob_keypair = Keypair::new();
|
|
|
|
|
2019-02-05 08:03:52 -08:00
|
|
|
info!(
|
|
|
|
"found leader: {:?}",
|
2019-03-06 18:53:59 -08:00
|
|
|
poll_gossip_for_leader(leader_data.gossip, Duration::from_secs(5)).unwrap()
|
2019-02-05 08:03:52 -08:00
|
|
|
);
|
|
|
|
|
2019-01-28 10:53:29 -08:00
|
|
|
let mut client = mk_client(&leader_data);
|
2019-03-02 10:25:16 -08:00
|
|
|
let blockhash = client.get_recent_blockhash();
|
|
|
|
info!("test_thin_client blockhash: {:?}", blockhash);
|
2018-09-04 21:33:19 -07:00
|
|
|
|
2019-02-26 16:35:00 -08:00
|
|
|
let starting_alice_balance = client.poll_get_balance(&alice.pubkey()).unwrap();
|
2019-03-05 16:28:14 -08:00
|
|
|
info!("Alice has {} lamports", starting_alice_balance);
|
2019-01-29 19:51:59 -08:00
|
|
|
|
2019-03-05 16:28:14 -08:00
|
|
|
info!("Give Bob 500 lamports");
|
2018-09-04 21:33:19 -07:00
|
|
|
let signature = client
|
2019-03-02 10:25:16 -08:00
|
|
|
.transfer(500, &alice, bob_keypair.pubkey(), &blockhash)
|
2018-09-04 21:33:19 -07:00
|
|
|
.unwrap();
|
2019-01-28 14:52:35 -08:00
|
|
|
client.poll_for_signature(&signature).unwrap();
|
2018-09-04 21:33:19 -07:00
|
|
|
|
2019-02-26 16:35:00 -08:00
|
|
|
let bob_balance = client.poll_get_balance(&bob_keypair.pubkey());
|
|
|
|
assert_eq!(bob_balance.unwrap(), 500);
|
2018-09-04 21:33:19 -07:00
|
|
|
|
2019-03-05 16:28:14 -08:00
|
|
|
info!("Take Bob's 500 lamports away");
|
2018-09-04 21:33:19 -07:00
|
|
|
let signature = client
|
2019-03-02 10:25:16 -08:00
|
|
|
.transfer(500, &bob_keypair, alice.pubkey(), &blockhash)
|
2018-09-04 21:33:19 -07:00
|
|
|
.unwrap();
|
2019-01-28 14:52:35 -08:00
|
|
|
client.poll_for_signature(&signature).unwrap();
|
2019-02-26 16:35:00 -08:00
|
|
|
let alice_balance = client.poll_get_balance(&alice.pubkey()).unwrap();
|
|
|
|
assert_eq!(alice_balance, starting_alice_balance);
|
2018-09-04 21:33:19 -07:00
|
|
|
|
2019-01-29 19:51:59 -08:00
|
|
|
info!("Should get an error when Bob's balance hits zero and is purged");
|
2019-02-26 16:35:00 -08:00
|
|
|
let bob_balance = client.poll_get_balance(&bob_keypair.pubkey());
|
|
|
|
info!("Bob's balance is {:?}", bob_balance);
|
|
|
|
assert!(bob_balance.is_err(),);
|
2018-09-04 21:33:19 -07:00
|
|
|
|
2019-03-03 16:44:06 -08:00
|
|
|
server.close().unwrap();
|
2018-09-04 21:33:19 -07:00
|
|
|
remove_dir_all(ledger_path).unwrap();
|
|
|
|
}
|
2018-05-04 11:11:39 -07:00
|
|
|
}
|