Derive retry timeout from slot duration

This commit is contained in:
Michael Vines 2019-02-27 13:54:08 -08:00
parent 163874d4da
commit 32aaa5fd06
1 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,7 @@
use reqwest;
use reqwest::header::CONTENT_TYPE;
use serde_json::{self, Value};
use solana_sdk::timing::{DEFAULT_TICKS_PER_SLOT, NUM_TICKS_PER_SECOND};
use std::net::SocketAddr;
use std::thread::sleep;
use std::time::Duration;
@ -84,8 +85,11 @@ impl RpcClient {
Err(e)?;
}
retries -= 1;
// TODO: Make the caller supply their desired retry frequency?
sleep(Duration::from_millis(500));
// Sleep for approximately half a slot
sleep(Duration::from_millis(
500 * DEFAULT_TICKS_PER_SLOT / NUM_TICKS_PER_SECOND as u64,
));
}
}
}