Use BlockCommitmentCache for RPC slots, take 2 (#11137)
* Use BlockCommitmentCache for RPC slots (#11103) * Add BankForks::highest_descendant(slot) * Update debug messages * Update core/src/rpc.rs Co-authored-by: Tyera Eulberg <teulberg@gmail.com> * cargo fmt * Remove highest_descendant * Fix test Co-authored-by: Tyera Eulberg <teulberg@gmail.com> * Fix crossed-in-flight compilation error Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use solana_sdk::clock::Slot;
|
||||
use solana_sdk::{clock::Slot, commitment_config::CommitmentLevel};
|
||||
use solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY;
|
||||
use std::collections::HashMap;
|
||||
|
||||
@ -103,6 +103,22 @@ impl BlockCommitmentCache {
|
||||
self.commitment_slots
|
||||
}
|
||||
|
||||
pub fn highest_gossip_confirmed_slot(&self) -> Slot {
|
||||
// TODO: see solana_core::RpcSubscriptions:
|
||||
//self.last_checked_slots.get(&CommitmentLevel::SingleGossip).unwrap_or(&0)
|
||||
self.highest_confirmed_slot()
|
||||
}
|
||||
|
||||
pub fn slot_with_commitment(&self, commitment_level: CommitmentLevel) -> Slot {
|
||||
match commitment_level {
|
||||
CommitmentLevel::Recent => self.slot(),
|
||||
CommitmentLevel::Root => self.root(),
|
||||
CommitmentLevel::Single => self.highest_confirmed_slot(),
|
||||
CommitmentLevel::SingleGossip => self.highest_gossip_confirmed_slot(),
|
||||
CommitmentLevel::Max => self.highest_confirmed_root(),
|
||||
}
|
||||
}
|
||||
|
||||
fn highest_slot_with_confirmation_count(&self, confirmation_count: usize) -> Slot {
|
||||
assert!(confirmation_count > 0 && confirmation_count <= MAX_LOCKOUT_HISTORY);
|
||||
for slot in (self.root()..self.slot()).rev() {
|
||||
|
Reference in New Issue
Block a user