Clean up type casts
This commit is contained in:
parent
a72325dbc2
commit
fdc31e99df
|
@ -343,7 +343,7 @@ impl Bank {
|
|||
tick_hash_queue.register_hash(hash);
|
||||
tick_hash_queue.hash_height()
|
||||
};
|
||||
if current_tick_height % NUM_TICKS_PER_SECOND as u64 == 0 {
|
||||
if current_tick_height % NUM_TICKS_PER_SECOND == 0 {
|
||||
self.status_cache.write().unwrap().new_cache(hash);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ impl HashQueue {
|
|||
|
||||
// this clean up can be deferred until sigs gets larger
|
||||
// because we verify entry.nth every place we check for validity
|
||||
if self.entries.len() >= MAX_RECENT_TICK_HASHES as usize {
|
||||
if self.entries.len() >= MAX_RECENT_TICK_HASHES {
|
||||
self.entries.retain(|_, entry| {
|
||||
hash_height - entry.hash_height <= MAX_RECENT_TICK_HASHES as u64
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
use std::time::Duration;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
pub const NUM_TICKS_PER_SECOND: usize = 10;
|
||||
pub const NUM_TICKS_PER_SECOND: u64 = 10;
|
||||
|
||||
// At 10 ticks/s, 8 ticks per slot implies that leader rotation and voting will happen
|
||||
// every 800 ms. A fast voting cadence ensures faster finality and convergence
|
||||
|
@ -17,7 +17,7 @@ pub const DEFAULT_SLOTS_PER_EPOCH: u64 = 64;
|
|||
/// not be processed by the network.
|
||||
pub const MAX_HASH_AGE_IN_SECONDS: usize = 120;
|
||||
|
||||
pub const MAX_RECENT_TICK_HASHES: usize = NUM_TICKS_PER_SECOND * MAX_HASH_AGE_IN_SECONDS;
|
||||
pub const MAX_RECENT_TICK_HASHES: usize = NUM_TICKS_PER_SECOND as usize * MAX_HASH_AGE_IN_SECONDS;
|
||||
|
||||
pub fn duration_as_us(d: &Duration) -> u64 {
|
||||
(d.as_secs() * 1000 * 1000) + (u64::from(d.subsec_nanos()) / 1_000)
|
||||
|
|
|
@ -172,11 +172,8 @@ impl BankingStage {
|
|||
// the likelihood of any single thread getting starved and processing old ids.
|
||||
// TODO: Banking stage threads should be prioritized to complete faster then this queue
|
||||
// expires.
|
||||
let (loaded_accounts, results) = bank.load_and_execute_transactions(
|
||||
txs,
|
||||
lock_results,
|
||||
MAX_RECENT_TICK_HASHES as usize / 2,
|
||||
);
|
||||
let (loaded_accounts, results) =
|
||||
bank.load_and_execute_transactions(txs, lock_results, MAX_RECENT_TICK_HASHES / 2);
|
||||
let load_execute_time = now.elapsed();
|
||||
|
||||
let record_time = {
|
||||
|
|
|
@ -25,7 +25,7 @@ pub enum PohServiceConfig {
|
|||
impl Default for PohServiceConfig {
|
||||
fn default() -> PohServiceConfig {
|
||||
// TODO: Change this to Tick to enable PoH
|
||||
PohServiceConfig::Sleep(Duration::from_millis(1000 / NUM_TICKS_PER_SECOND as u64))
|
||||
PohServiceConfig::Sleep(Duration::from_millis(1000 / NUM_TICKS_PER_SECOND))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ impl RpcClient {
|
|||
|
||||
// Sleep for approximately half a slot
|
||||
sleep(Duration::from_millis(
|
||||
500 * DEFAULT_TICKS_PER_SLOT / NUM_TICKS_PER_SECOND as u64,
|
||||
500 * DEFAULT_TICKS_PER_SLOT / NUM_TICKS_PER_SECOND,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -754,7 +754,7 @@ fn get_next_last_id(
|
|||
next_last_id_retries -= 1;
|
||||
// Retry ~twice during a slot
|
||||
sleep(Duration::from_millis(
|
||||
500 * DEFAULT_TICKS_PER_SLOT / NUM_TICKS_PER_SECOND as u64,
|
||||
500 * DEFAULT_TICKS_PER_SLOT / NUM_TICKS_PER_SECOND,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -816,7 +816,7 @@ fn send_and_confirm_transaction(
|
|||
if cfg!(not(test)) {
|
||||
// Retry ~twice during a slot
|
||||
sleep(Duration::from_millis(
|
||||
500 * DEFAULT_TICKS_PER_SLOT / NUM_TICKS_PER_SECOND as u64,
|
||||
500 * DEFAULT_TICKS_PER_SLOT / NUM_TICKS_PER_SECOND,
|
||||
));
|
||||
}
|
||||
};
|
||||
|
@ -857,7 +857,7 @@ fn send_and_confirm_transactions(
|
|||
if cfg!(not(test)) {
|
||||
// Delay ~1 tick between write transactions in an attempt to reduce AccountInUse errors
|
||||
// since all the write transactions modify the same program account
|
||||
sleep(Duration::from_millis(1000 / NUM_TICKS_PER_SECOND as u64));
|
||||
sleep(Duration::from_millis(1000 / NUM_TICKS_PER_SECOND));
|
||||
}
|
||||
|
||||
let signature = send_transaction(&rpc_client, &transaction).ok();
|
||||
|
@ -871,7 +871,7 @@ fn send_and_confirm_transactions(
|
|||
if cfg!(not(test)) {
|
||||
// Retry ~twice during a slot
|
||||
sleep(Duration::from_millis(
|
||||
500 * DEFAULT_TICKS_PER_SLOT / NUM_TICKS_PER_SECOND as u64,
|
||||
500 * DEFAULT_TICKS_PER_SLOT / NUM_TICKS_PER_SECOND,
|
||||
));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue