Skip to content

Commit

Permalink
TpuClient now uses the processed slot to seed its leader schedule cache
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Sep 8, 2021
1 parent 38bbb77 commit b83284c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions client/src/tpu_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ use crate::{
};
use bincode::serialize;
use log::*;
use solana_sdk::{clock::Slot, pubkey::Pubkey, transaction::Transaction};
use solana_sdk::{
clock::Slot, commitment_config::CommitmentConfig, pubkey::Pubkey, transaction::Transaction,
};
use std::{
collections::{HashMap, HashSet, VecDeque},
net::{SocketAddr, UdpSocket},
Expand Down Expand Up @@ -151,7 +153,12 @@ impl LeaderTpuCache {
}
} else {
// Overran the local leader schedule cache
warn!("Leader not known for slot {}", leader_slot);
warn!(
"Leader not known for slot {}; cache holds slots [{},{}]",
leader_slot,
self.first_slot,
self.last_slot()
);
}
}
leader_sockets
Expand Down Expand Up @@ -249,7 +256,7 @@ struct LeaderTpuService {

impl LeaderTpuService {
fn new(rpc_client: Arc<RpcClient>, websocket_url: &str, exit: Arc<AtomicBool>) -> Result<Self> {
let start_slot = rpc_client.get_max_shred_insert_slot()?;
let start_slot = rpc_client.get_slot_with_commitment(CommitmentConfig::processed())?;

let recent_slots = RecentLeaderSlots::new(start_slot);
let leader_tpu_cache = Arc::new(RwLock::new(LeaderTpuCache::new(&rpc_client, start_slot)?));
Expand All @@ -268,7 +275,6 @@ impl LeaderTpuService {
SlotUpdate::FirstShredReceived { slot, .. } => slot,
_ => return,
};

recent_slots.record_slot(current_slot);
},
)?)
Expand Down

0 comments on commit b83284c

Please sign in to comment.