Retry rpc requests on connection failures

Applied a blanket default retry count of 5, which seems like enough but
not excessive retries.
This commit is contained in:
Michael Vines
2019-01-15 12:54:48 -08:00
parent 4d9489aeb1
commit b1e57e2a30
2 changed files with 27 additions and 16 deletions

View File

@@ -24,14 +24,13 @@ impl MockRpcClient {
pub fn new(addr: String) -> Self {
MockRpcClient { addr }
}
}
impl RpcRequestHandler for MockRpcClient {
fn make_rpc_request(
pub fn retry_make_rpc_request(
&self,
_id: u64,
request: RpcRequest,
request: &RpcRequest,
params: Option<Value>,
mut _retries: usize,
) -> Result<Value, Box<dyn error::Error>> {
if self.addr == "fails" {
return Ok(Value::Null);
@@ -71,6 +70,17 @@ impl RpcRequestHandler for MockRpcClient {
}
}
impl RpcRequestHandler for MockRpcClient {
fn make_rpc_request(
&self,
id: u64,
request: RpcRequest,
params: Option<Value>,
) -> Result<Value, Box<dyn error::Error>> {
self.retry_make_rpc_request(id, &request, params, 0)
}
}
pub fn request_airdrop_transaction(
_drone_addr: &SocketAddr,
_id: &Pubkey,