Add some optimizing to ThinClient (#4112)

Can create a multi-socketed ThinClient which will use request time
from get_recent_blockhash to tune for the best node to talk to.
This commit is contained in:
sakridge
2019-05-27 20:54:44 -07:00
committed by GitHub
parent 13c2e50b38
commit 5340800cea
8 changed files with 239 additions and 49 deletions

View File

@@ -36,7 +36,18 @@ pub fn sample_txs<T>(
total_elapsed = start_time.elapsed();
let elapsed = now.elapsed();
now = Instant::now();
let mut txs = client.get_transaction_count().expect("transaction count");
let mut txs;
match client.get_transaction_count() {
Err(e) => {
// ThinClient with multiple options should pick a better one now.
info!("Couldn't get transaction count {:?}", e);
sleep(Duration::from_secs(sample_period));
continue;
}
Ok(tx_count) => {
txs = tx_count;
}
}
if txs < last_txs {
info!("Expected txs({}) >= last_txs({})", txs, last_txs);