Clean up stray retry_get_balance() function
This commit is contained in:
@ -204,6 +204,29 @@ impl RpcClient {
|
||||
self.poll_balance_with_timeout(pubkey, &Duration::from_millis(100), &Duration::from_secs(1))
|
||||
}
|
||||
|
||||
pub fn wait_for_balance(&self, pubkey: &Pubkey, expected_balance: Option<u64>) -> Option<u64> {
|
||||
const LAST: usize = 30;
|
||||
for run in 0..LAST {
|
||||
let balance_result = self.poll_get_balance(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
|
||||
}
|
||||
|
||||
/// Poll the server to confirm a transaction.
|
||||
pub fn poll_for_signature(&self, signature: &Signature) -> io::Result<()> {
|
||||
let now = Instant::now();
|
||||
|
@ -137,6 +137,10 @@ impl ThinClient {
|
||||
self.rpc_client.poll_get_balance(pubkey)
|
||||
}
|
||||
|
||||
pub fn wait_for_balance(&self, pubkey: &Pubkey, expected_balance: Option<u64>) -> Option<u64> {
|
||||
self.rpc_client.wait_for_balance(pubkey, expected_balance)
|
||||
}
|
||||
|
||||
pub fn poll_for_signature(&self, signature: &Signature) -> io::Result<()> {
|
||||
self.rpc_client.poll_for_signature(signature)
|
||||
}
|
||||
@ -163,29 +167,3 @@ pub fn create_client_with_timeout(
|
||||
let (_, transactions_socket) = solana_netutil::bind_in_range(range).unwrap();
|
||||
ThinClient::new_socket_with_timeout(rpc, tpu, transactions_socket, timeout)
|
||||
}
|
||||
|
||||
pub fn retry_get_balance(
|
||||
client: &ThinClient,
|
||||
bob_pubkey: &Pubkey,
|
||||
expected_balance: Option<u64>,
|
||||
) -> Option<u64> {
|
||||
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
|
||||
}
|
||||
|
Reference in New Issue
Block a user