Add signature polling to SyncClient (#3996)

automerge
This commit is contained in:
Sagar Dhawan
2019-04-25 12:46:40 -07:00
committed by Grimes
parent d12705f9b0
commit a3c302c36a
6 changed files with 102 additions and 21 deletions

View File

@ -17,7 +17,7 @@ use solana_sdk::system_transaction;
use solana_sdk::timing::{
duration_as_ms, DEFAULT_TICKS_PER_SLOT, NUM_CONSECUTIVE_LEADER_SLOTS, NUM_TICKS_PER_SECOND,
};
use std::io;
use solana_sdk::transport::TransportError;
use std::thread::sleep;
use std::time::Duration;
@ -202,7 +202,7 @@ pub fn kill_entry_and_spend_and_verify_rest(
);
match sig {
Err(e) => {
result = Err(e);
result = Err(TransportError::IoError(e));
continue;
}
@ -227,7 +227,7 @@ fn poll_all_nodes_for_signature(
cluster_nodes: &[ContactInfo],
sig: &Signature,
confs: usize,
) -> io::Result<()> {
) -> Result<(), TransportError> {
for validator in cluster_nodes {
if validator.id == entry_point_info.id {
continue;

View File

@ -25,6 +25,7 @@ use solana_sdk::hash::{Hash, Hasher};
use solana_sdk::signature::{Keypair, KeypairUtil, Signature};
use solana_sdk::system_transaction;
use solana_sdk::transaction::Transaction;
use solana_sdk::transport::TransportError;
use solana_storage_api::storage_instruction;
use std::fs::File;
use std::io;
@ -405,7 +406,7 @@ impl Replicator {
client: &ThinClient,
keypair: &Keypair,
storage_keypair: &Keypair,
) -> io::Result<()> {
) -> Result<()> {
// make sure replicator has some balance
if client.poll_get_balance(&keypair.pubkey())? == 0 {
Err(io::Error::new(
@ -429,7 +430,14 @@ impl Replicator {
0,
);
let signature = client.async_send_transaction(tx)?;
client.poll_for_signature(&signature)?;
client
.poll_for_signature(&signature)
.map_err(|err| match err {
TransportError::IoError(e) => e,
TransportError::TransactionError(_) => {
io::Error::new(ErrorKind::Other, "signature not found")
}
})?;
}
Ok(())
}