Rename CacheSlotInfo to CommitmentSlots (#11111)
This commit is contained in:
parent
d0d4d9b3d1
commit
a255b0fc86
|
@ -3,7 +3,7 @@ use solana_measure::measure::Measure;
|
||||||
use solana_metrics::datapoint_info;
|
use solana_metrics::datapoint_info;
|
||||||
use solana_runtime::{
|
use solana_runtime::{
|
||||||
bank::Bank,
|
bank::Bank,
|
||||||
commitment::{BlockCommitment, BlockCommitmentCache, CacheSlotInfo, VOTE_THRESHOLD_SIZE},
|
commitment::{BlockCommitment, BlockCommitmentCache, CommitmentSlots, VOTE_THRESHOLD_SIZE},
|
||||||
};
|
};
|
||||||
use solana_sdk::clock::Slot;
|
use solana_sdk::clock::Slot;
|
||||||
use solana_vote_program::vote_state::VoteState;
|
use solana_vote_program::vote_state::VoteState;
|
||||||
|
@ -112,7 +112,7 @@ impl AggregateCommitmentService {
|
||||||
let mut new_block_commitment = BlockCommitmentCache::new(
|
let mut new_block_commitment = BlockCommitmentCache::new(
|
||||||
block_commitment,
|
block_commitment,
|
||||||
aggregation_data.total_stake,
|
aggregation_data.total_stake,
|
||||||
CacheSlotInfo {
|
CommitmentSlots {
|
||||||
slot: aggregation_data.bank.slot(),
|
slot: aggregation_data.bank.slot(),
|
||||||
root: aggregation_data.root,
|
root: aggregation_data.root,
|
||||||
highest_confirmed_slot: aggregation_data.root,
|
highest_confirmed_slot: aggregation_data.root,
|
||||||
|
@ -138,7 +138,7 @@ impl AggregateCommitmentService {
|
||||||
// Triggers rpc_subscription notifications as soon as new commitment data is available,
|
// Triggers rpc_subscription notifications as soon as new commitment data is available,
|
||||||
// sending just the commitment cache slot information that the notifications thread
|
// sending just the commitment cache slot information that the notifications thread
|
||||||
// needs
|
// needs
|
||||||
subscriptions.notify_subscribers(w_block_commitment_cache.slot_info());
|
subscriptions.notify_subscribers(w_block_commitment_cache.commitment_slots());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ use solana_runtime::{
|
||||||
accounts::AccountAddressFilter,
|
accounts::AccountAddressFilter,
|
||||||
bank::Bank,
|
bank::Bank,
|
||||||
bank_forks::BankForks,
|
bank_forks::BankForks,
|
||||||
commitment::{BlockCommitmentArray, BlockCommitmentCache, CacheSlotInfo},
|
commitment::{BlockCommitmentArray, BlockCommitmentCache, CommitmentSlots},
|
||||||
log_collector::LogCollector,
|
log_collector::LogCollector,
|
||||||
send_transaction_service::{SendTransactionService, TransactionInfo},
|
send_transaction_service::{SendTransactionService, TransactionInfo},
|
||||||
};
|
};
|
||||||
|
@ -192,7 +192,7 @@ impl JsonRpcRequestProcessor {
|
||||||
block_commitment_cache: Arc::new(RwLock::new(BlockCommitmentCache::new(
|
block_commitment_cache: Arc::new(RwLock::new(BlockCommitmentCache::new(
|
||||||
HashMap::new(),
|
HashMap::new(),
|
||||||
0,
|
0,
|
||||||
CacheSlotInfo {
|
CommitmentSlots {
|
||||||
slot: bank.slot(),
|
slot: bank.slot(),
|
||||||
root: 0,
|
root: 0,
|
||||||
highest_confirmed_slot: 0,
|
highest_confirmed_slot: 0,
|
||||||
|
@ -1819,7 +1819,7 @@ pub mod tests {
|
||||||
let block_commitment_cache = Arc::new(RwLock::new(BlockCommitmentCache::new(
|
let block_commitment_cache = Arc::new(RwLock::new(BlockCommitmentCache::new(
|
||||||
block_commitment,
|
block_commitment,
|
||||||
10,
|
10,
|
||||||
CacheSlotInfo {
|
CommitmentSlots {
|
||||||
slot: bank.slot(),
|
slot: bank.slot(),
|
||||||
root: 0,
|
root: 0,
|
||||||
highest_confirmed_slot: 0,
|
highest_confirmed_slot: 0,
|
||||||
|
@ -3334,7 +3334,7 @@ pub mod tests {
|
||||||
let block_commitment_cache = Arc::new(RwLock::new(BlockCommitmentCache::new(
|
let block_commitment_cache = Arc::new(RwLock::new(BlockCommitmentCache::new(
|
||||||
block_commitment,
|
block_commitment,
|
||||||
42,
|
42,
|
||||||
CacheSlotInfo {
|
CommitmentSlots {
|
||||||
slot: bank_forks.read().unwrap().highest_slot(),
|
slot: bank_forks.read().unwrap().highest_slot(),
|
||||||
root: 0,
|
root: 0,
|
||||||
highest_confirmed_slot: 0,
|
highest_confirmed_slot: 0,
|
||||||
|
@ -3863,7 +3863,7 @@ pub mod tests {
|
||||||
let block_commitment_cache = BlockCommitmentCache::new(
|
let block_commitment_cache = BlockCommitmentCache::new(
|
||||||
block_commitment,
|
block_commitment,
|
||||||
50,
|
50,
|
||||||
CacheSlotInfo {
|
CommitmentSlots {
|
||||||
slot: bank.slot(),
|
slot: bank.slot(),
|
||||||
root: 0,
|
root: 0,
|
||||||
highest_confirmed_slot: 0,
|
highest_confirmed_slot: 0,
|
||||||
|
|
|
@ -359,7 +359,7 @@ mod tests {
|
||||||
use solana_runtime::{
|
use solana_runtime::{
|
||||||
bank::Bank,
|
bank::Bank,
|
||||||
bank_forks::BankForks,
|
bank_forks::BankForks,
|
||||||
commitment::{BlockCommitmentCache, CacheSlotInfo},
|
commitment::{BlockCommitmentCache, CommitmentSlots},
|
||||||
genesis_utils::{
|
genesis_utils::{
|
||||||
create_genesis_config, create_genesis_config_with_vote_accounts, GenesisConfigInfo,
|
create_genesis_config, create_genesis_config_with_vote_accounts, GenesisConfigInfo,
|
||||||
ValidatorVoteKeypairs,
|
ValidatorVoteKeypairs,
|
||||||
|
@ -392,9 +392,9 @@ mod tests {
|
||||||
.get(current_slot)
|
.get(current_slot)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.process_transaction(tx)?;
|
.process_transaction(tx)?;
|
||||||
let mut cache_slot_info = CacheSlotInfo::default();
|
let mut commitment_slots = CommitmentSlots::default();
|
||||||
cache_slot_info.slot = current_slot;
|
commitment_slots.slot = current_slot;
|
||||||
subscriptions.notify_subscribers(cache_slot_info);
|
subscriptions.notify_subscribers(commitment_slots);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -687,7 +687,7 @@ mod tests {
|
||||||
.process_transaction(&tx)
|
.process_transaction(&tx)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
rpc.subscriptions
|
rpc.subscriptions
|
||||||
.notify_subscribers(CacheSlotInfo::default());
|
.notify_subscribers(CommitmentSlots::default());
|
||||||
// allow 200ms for notification thread to wake
|
// allow 200ms for notification thread to wake
|
||||||
std::thread::sleep(Duration::from_millis(200));
|
std::thread::sleep(Duration::from_millis(200));
|
||||||
let _panic = robust_poll_or_panic(receiver);
|
let _panic = robust_poll_or_panic(receiver);
|
||||||
|
@ -732,17 +732,17 @@ mod tests {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.process_transaction(&tx)
|
.process_transaction(&tx)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut cache_slot_info = CacheSlotInfo::default();
|
let mut commitment_slots = CommitmentSlots::default();
|
||||||
cache_slot_info.slot = 1;
|
commitment_slots.slot = 1;
|
||||||
rpc.subscriptions.notify_subscribers(cache_slot_info);
|
rpc.subscriptions.notify_subscribers(commitment_slots);
|
||||||
|
|
||||||
let cache_slot_info = CacheSlotInfo {
|
let commitment_slots = CommitmentSlots {
|
||||||
slot: 2,
|
slot: 2,
|
||||||
root: 1,
|
root: 1,
|
||||||
highest_confirmed_slot: 1,
|
highest_confirmed_slot: 1,
|
||||||
highest_confirmed_root: 1,
|
highest_confirmed_root: 1,
|
||||||
};
|
};
|
||||||
rpc.subscriptions.notify_subscribers(cache_slot_info);
|
rpc.subscriptions.notify_subscribers(commitment_slots);
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"method": "accountNotification",
|
"method": "accountNotification",
|
||||||
|
|
|
@ -14,7 +14,7 @@ use solana_client::rpc_response::{
|
||||||
use solana_runtime::{
|
use solana_runtime::{
|
||||||
bank::Bank,
|
bank::Bank,
|
||||||
bank_forks::BankForks,
|
bank_forks::BankForks,
|
||||||
commitment::{BlockCommitmentCache, CacheSlotInfo},
|
commitment::{BlockCommitmentCache, CommitmentSlots},
|
||||||
};
|
};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
account::Account,
|
account::Account,
|
||||||
|
@ -60,7 +60,7 @@ enum NotificationEntry {
|
||||||
Vote(Vote),
|
Vote(Vote),
|
||||||
Root(Slot),
|
Root(Slot),
|
||||||
Frozen(Slot),
|
Frozen(Slot),
|
||||||
Bank(CacheSlotInfo),
|
Bank(CommitmentSlots),
|
||||||
Gossip(Slot),
|
Gossip(Slot),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,8 +71,8 @@ impl std::fmt::Debug for NotificationEntry {
|
||||||
NotificationEntry::Frozen(slot) => write!(f, "Frozen({})", slot),
|
NotificationEntry::Frozen(slot) => write!(f, "Frozen({})", slot),
|
||||||
NotificationEntry::Vote(vote) => write!(f, "Vote({:?})", vote),
|
NotificationEntry::Vote(vote) => write!(f, "Vote({:?})", vote),
|
||||||
NotificationEntry::Slot(slot_info) => write!(f, "Slot({:?})", slot_info),
|
NotificationEntry::Slot(slot_info) => write!(f, "Slot({:?})", slot_info),
|
||||||
NotificationEntry::Bank(cache_slot_info) => {
|
NotificationEntry::Bank(commitment_slots) => {
|
||||||
write!(f, "Bank({{slot: {:?}}})", cache_slot_info.slot)
|
write!(f, "Bank({{slot: {:?}}})", commitment_slots.slot)
|
||||||
}
|
}
|
||||||
NotificationEntry::Gossip(slot) => write!(f, "Gossip({:?})", slot),
|
NotificationEntry::Gossip(slot) => write!(f, "Gossip({:?})", slot),
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ fn check_commitment_and_notify<K, S, B, F, X>(
|
||||||
subscriptions: &HashMap<K, HashMap<SubscriptionId, SubscriptionData<Response<S>>>>,
|
subscriptions: &HashMap<K, HashMap<SubscriptionId, SubscriptionData<Response<S>>>>,
|
||||||
hashmap_key: &K,
|
hashmap_key: &K,
|
||||||
bank_forks: &Arc<RwLock<BankForks>>,
|
bank_forks: &Arc<RwLock<BankForks>>,
|
||||||
cache_slot_info: &CacheSlotInfo,
|
commitment_slots: &CommitmentSlots,
|
||||||
bank_method: B,
|
bank_method: B,
|
||||||
filter_results: F,
|
filter_results: F,
|
||||||
notifier: &RpcNotifier,
|
notifier: &RpcNotifier,
|
||||||
|
@ -173,11 +173,11 @@ where
|
||||||
) in hashmap.iter()
|
) in hashmap.iter()
|
||||||
{
|
{
|
||||||
let slot = match commitment.commitment {
|
let slot = match commitment.commitment {
|
||||||
CommitmentLevel::Max => cache_slot_info.highest_confirmed_root,
|
CommitmentLevel::Max => commitment_slots.highest_confirmed_root,
|
||||||
CommitmentLevel::Recent => cache_slot_info.slot,
|
CommitmentLevel::Recent => commitment_slots.slot,
|
||||||
CommitmentLevel::Root => cache_slot_info.root,
|
CommitmentLevel::Root => commitment_slots.root,
|
||||||
CommitmentLevel::Single | CommitmentLevel::SingleGossip => {
|
CommitmentLevel::Single | CommitmentLevel::SingleGossip => {
|
||||||
cache_slot_info.highest_confirmed_slot
|
commitment_slots.highest_confirmed_slot
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let results = {
|
let results = {
|
||||||
|
@ -387,14 +387,14 @@ impl RpcSubscriptions {
|
||||||
bank_forks: &Arc<RwLock<BankForks>>,
|
bank_forks: &Arc<RwLock<BankForks>>,
|
||||||
account_subscriptions: Arc<RpcAccountSubscriptions>,
|
account_subscriptions: Arc<RpcAccountSubscriptions>,
|
||||||
notifier: &RpcNotifier,
|
notifier: &RpcNotifier,
|
||||||
cache_slot_info: &CacheSlotInfo,
|
commitment_slots: &CommitmentSlots,
|
||||||
) {
|
) {
|
||||||
let subscriptions = account_subscriptions.read().unwrap();
|
let subscriptions = account_subscriptions.read().unwrap();
|
||||||
check_commitment_and_notify(
|
check_commitment_and_notify(
|
||||||
&subscriptions,
|
&subscriptions,
|
||||||
pubkey,
|
pubkey,
|
||||||
bank_forks,
|
bank_forks,
|
||||||
cache_slot_info,
|
commitment_slots,
|
||||||
Bank::get_account_modified_slot,
|
Bank::get_account_modified_slot,
|
||||||
filter_account_result,
|
filter_account_result,
|
||||||
notifier,
|
notifier,
|
||||||
|
@ -406,14 +406,14 @@ impl RpcSubscriptions {
|
||||||
bank_forks: &Arc<RwLock<BankForks>>,
|
bank_forks: &Arc<RwLock<BankForks>>,
|
||||||
program_subscriptions: Arc<RpcProgramSubscriptions>,
|
program_subscriptions: Arc<RpcProgramSubscriptions>,
|
||||||
notifier: &RpcNotifier,
|
notifier: &RpcNotifier,
|
||||||
cache_slot_info: &CacheSlotInfo,
|
commitment_slots: &CommitmentSlots,
|
||||||
) {
|
) {
|
||||||
let subscriptions = program_subscriptions.read().unwrap();
|
let subscriptions = program_subscriptions.read().unwrap();
|
||||||
check_commitment_and_notify(
|
check_commitment_and_notify(
|
||||||
&subscriptions,
|
&subscriptions,
|
||||||
program_id,
|
program_id,
|
||||||
bank_forks,
|
bank_forks,
|
||||||
cache_slot_info,
|
commitment_slots,
|
||||||
Bank::get_program_accounts_modified_since_parent,
|
Bank::get_program_accounts_modified_since_parent,
|
||||||
filter_program_results,
|
filter_program_results,
|
||||||
notifier,
|
notifier,
|
||||||
|
@ -425,14 +425,14 @@ impl RpcSubscriptions {
|
||||||
bank_forks: &Arc<RwLock<BankForks>>,
|
bank_forks: &Arc<RwLock<BankForks>>,
|
||||||
signature_subscriptions: Arc<RpcSignatureSubscriptions>,
|
signature_subscriptions: Arc<RpcSignatureSubscriptions>,
|
||||||
notifier: &RpcNotifier,
|
notifier: &RpcNotifier,
|
||||||
cache_slot_info: &CacheSlotInfo,
|
commitment_slots: &CommitmentSlots,
|
||||||
) {
|
) {
|
||||||
let mut subscriptions = signature_subscriptions.write().unwrap();
|
let mut subscriptions = signature_subscriptions.write().unwrap();
|
||||||
let notified_ids = check_commitment_and_notify(
|
let notified_ids = check_commitment_and_notify(
|
||||||
&subscriptions,
|
&subscriptions,
|
||||||
signature,
|
signature,
|
||||||
bank_forks,
|
bank_forks,
|
||||||
cache_slot_info,
|
commitment_slots,
|
||||||
Bank::get_signature_status_processed_since_parent,
|
Bank::get_signature_status_processed_since_parent,
|
||||||
filter_signature_result,
|
filter_signature_result,
|
||||||
notifier,
|
notifier,
|
||||||
|
@ -605,8 +605,8 @@ impl RpcSubscriptions {
|
||||||
|
|
||||||
/// Notify subscribers of changes to any accounts or new signatures since
|
/// Notify subscribers of changes to any accounts or new signatures since
|
||||||
/// the bank's last checkpoint.
|
/// the bank's last checkpoint.
|
||||||
pub fn notify_subscribers(&self, cache_slot_info: CacheSlotInfo) {
|
pub fn notify_subscribers(&self, commitment_slots: CommitmentSlots) {
|
||||||
self.enqueue_notification(NotificationEntry::Bank(cache_slot_info));
|
self.enqueue_notification(NotificationEntry::Bank(commitment_slots));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Notify SingleGossip commitment-level subscribers of changes to any accounts or new
|
/// Notify SingleGossip commitment-level subscribers of changes to any accounts or new
|
||||||
|
@ -730,13 +730,13 @@ impl RpcSubscriptions {
|
||||||
.filter(|&s| s > root)
|
.filter(|&s| s > root)
|
||||||
.collect();
|
.collect();
|
||||||
}
|
}
|
||||||
NotificationEntry::Bank(cache_slot_info) => {
|
NotificationEntry::Bank(commitment_slots) => {
|
||||||
RpcSubscriptions::notify_accounts_programs_signatures(
|
RpcSubscriptions::notify_accounts_programs_signatures(
|
||||||
&subscriptions.account_subscriptions,
|
&subscriptions.account_subscriptions,
|
||||||
&subscriptions.program_subscriptions,
|
&subscriptions.program_subscriptions,
|
||||||
&subscriptions.signature_subscriptions,
|
&subscriptions.signature_subscriptions,
|
||||||
&bank_forks,
|
&bank_forks,
|
||||||
&cache_slot_info,
|
&commitment_slots,
|
||||||
¬ifier,
|
¬ifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -805,16 +805,16 @@ impl RpcSubscriptions {
|
||||||
|
|
||||||
drop(last_checked_slots_lock);
|
drop(last_checked_slots_lock);
|
||||||
|
|
||||||
let cache_slot_info = CacheSlotInfo {
|
let commitment_slots = CommitmentSlots {
|
||||||
highest_confirmed_slot: slot,
|
highest_confirmed_slot: slot,
|
||||||
..CacheSlotInfo::default()
|
..CommitmentSlots::default()
|
||||||
};
|
};
|
||||||
RpcSubscriptions::notify_accounts_programs_signatures(
|
RpcSubscriptions::notify_accounts_programs_signatures(
|
||||||
&subscriptions.gossip_account_subscriptions,
|
&subscriptions.gossip_account_subscriptions,
|
||||||
&subscriptions.gossip_program_subscriptions,
|
&subscriptions.gossip_program_subscriptions,
|
||||||
&subscriptions.gossip_signature_subscriptions,
|
&subscriptions.gossip_signature_subscriptions,
|
||||||
&bank_forks,
|
&bank_forks,
|
||||||
&cache_slot_info,
|
&commitment_slots,
|
||||||
¬ifier,
|
¬ifier,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -824,7 +824,7 @@ impl RpcSubscriptions {
|
||||||
program_subscriptions: &Arc<RpcProgramSubscriptions>,
|
program_subscriptions: &Arc<RpcProgramSubscriptions>,
|
||||||
signature_subscriptions: &Arc<RpcSignatureSubscriptions>,
|
signature_subscriptions: &Arc<RpcSignatureSubscriptions>,
|
||||||
bank_forks: &Arc<RwLock<BankForks>>,
|
bank_forks: &Arc<RwLock<BankForks>>,
|
||||||
cache_slot_info: &CacheSlotInfo,
|
commitment_slots: &CommitmentSlots,
|
||||||
notifier: &RpcNotifier,
|
notifier: &RpcNotifier,
|
||||||
) {
|
) {
|
||||||
let pubkeys: Vec<_> = {
|
let pubkeys: Vec<_> = {
|
||||||
|
@ -837,7 +837,7 @@ impl RpcSubscriptions {
|
||||||
&bank_forks,
|
&bank_forks,
|
||||||
account_subscriptions.clone(),
|
account_subscriptions.clone(),
|
||||||
¬ifier,
|
¬ifier,
|
||||||
&cache_slot_info,
|
&commitment_slots,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -851,7 +851,7 @@ impl RpcSubscriptions {
|
||||||
&bank_forks,
|
&bank_forks,
|
||||||
program_subscriptions.clone(),
|
program_subscriptions.clone(),
|
||||||
¬ifier,
|
¬ifier,
|
||||||
&cache_slot_info,
|
&commitment_slots,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,7 +865,7 @@ impl RpcSubscriptions {
|
||||||
&bank_forks,
|
&bank_forks,
|
||||||
signature_subscriptions.clone(),
|
signature_subscriptions.clone(),
|
||||||
¬ifier,
|
¬ifier,
|
||||||
&cache_slot_info,
|
&commitment_slots,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -988,9 +988,9 @@ pub(crate) mod tests {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.process_transaction(&tx)
|
.process_transaction(&tx)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut cache_slot_info = CacheSlotInfo::default();
|
let mut commitment_slots = CommitmentSlots::default();
|
||||||
cache_slot_info.slot = 1;
|
commitment_slots.slot = 1;
|
||||||
subscriptions.notify_subscribers(cache_slot_info);
|
subscriptions.notify_subscribers(commitment_slots);
|
||||||
let (response, _) = robust_poll_or_panic(transport_receiver);
|
let (response, _) = robust_poll_or_panic(transport_receiver);
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
|
@ -1071,7 +1071,7 @@ pub(crate) mod tests {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.contains_key(&solana_budget_program::id()));
|
.contains_key(&solana_budget_program::id()));
|
||||||
|
|
||||||
subscriptions.notify_subscribers(CacheSlotInfo::default());
|
subscriptions.notify_subscribers(CommitmentSlots::default());
|
||||||
let (response, _) = robust_poll_or_panic(transport_receiver);
|
let (response, _) = robust_poll_or_panic(transport_receiver);
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
|
@ -1153,7 +1153,7 @@ pub(crate) mod tests {
|
||||||
let block_commitment_cache = BlockCommitmentCache::new(
|
let block_commitment_cache = BlockCommitmentCache::new(
|
||||||
block_commitment,
|
block_commitment,
|
||||||
10,
|
10,
|
||||||
CacheSlotInfo {
|
CommitmentSlots {
|
||||||
slot: bank1.slot(),
|
slot: bank1.slot(),
|
||||||
root: 0,
|
root: 0,
|
||||||
highest_confirmed_slot: 0,
|
highest_confirmed_slot: 0,
|
||||||
|
@ -1210,9 +1210,9 @@ pub(crate) mod tests {
|
||||||
assert!(sig_subs.contains_key(&unprocessed_tx.signatures[0]));
|
assert!(sig_subs.contains_key(&unprocessed_tx.signatures[0]));
|
||||||
assert!(sig_subs.contains_key(&processed_tx.signatures[0]));
|
assert!(sig_subs.contains_key(&processed_tx.signatures[0]));
|
||||||
}
|
}
|
||||||
let mut cache_slot_info = CacheSlotInfo::default();
|
let mut commitment_slots = CommitmentSlots::default();
|
||||||
cache_slot_info.slot = 1;
|
commitment_slots.slot = 1;
|
||||||
subscriptions.notify_subscribers(cache_slot_info);
|
subscriptions.notify_subscribers(commitment_slots);
|
||||||
let expected_res = RpcSignatureResult { err: None };
|
let expected_res = RpcSignatureResult { err: None };
|
||||||
|
|
||||||
struct Notification {
|
struct Notification {
|
||||||
|
|
|
@ -43,7 +43,7 @@ pub struct BlockCommitmentCache {
|
||||||
block_commitment: HashMap<Slot, BlockCommitment>,
|
block_commitment: HashMap<Slot, BlockCommitment>,
|
||||||
/// Cache slot details. Cluster data is calculated from the block_commitment map, and cached in
|
/// Cache slot details. Cluster data is calculated from the block_commitment map, and cached in
|
||||||
/// the struct to avoid the expense of recalculating on every call.
|
/// the struct to avoid the expense of recalculating on every call.
|
||||||
slot_info: CacheSlotInfo,
|
commitment_slots: CommitmentSlots,
|
||||||
/// Total stake active during the bank's epoch
|
/// Total stake active during the bank's epoch
|
||||||
total_stake: u64,
|
total_stake: u64,
|
||||||
}
|
}
|
||||||
|
@ -55,9 +55,9 @@ impl std::fmt::Debug for BlockCommitmentCache {
|
||||||
.field("total_stake", &self.total_stake)
|
.field("total_stake", &self.total_stake)
|
||||||
.field(
|
.field(
|
||||||
"bank",
|
"bank",
|
||||||
&format_args!("Bank({{current_slot: {:?}}})", self.slot_info.slot),
|
&format_args!("Bank({{current_slot: {:?}}})", self.commitment_slots.slot),
|
||||||
)
|
)
|
||||||
.field("root", &self.slot_info.root)
|
.field("root", &self.commitment_slots.root)
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,12 +66,12 @@ impl BlockCommitmentCache {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
block_commitment: HashMap<Slot, BlockCommitment>,
|
block_commitment: HashMap<Slot, BlockCommitment>,
|
||||||
total_stake: u64,
|
total_stake: u64,
|
||||||
slot_info: CacheSlotInfo,
|
commitment_slots: CommitmentSlots,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
block_commitment,
|
block_commitment,
|
||||||
total_stake,
|
total_stake,
|
||||||
slot_info,
|
commitment_slots,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,23 +84,23 @@ impl BlockCommitmentCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn slot(&self) -> Slot {
|
pub fn slot(&self) -> Slot {
|
||||||
self.slot_info.slot
|
self.commitment_slots.slot
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn root(&self) -> Slot {
|
pub fn root(&self) -> Slot {
|
||||||
self.slot_info.root
|
self.commitment_slots.root
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn highest_confirmed_slot(&self) -> Slot {
|
pub fn highest_confirmed_slot(&self) -> Slot {
|
||||||
self.slot_info.highest_confirmed_slot
|
self.commitment_slots.highest_confirmed_slot
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn highest_confirmed_root(&self) -> Slot {
|
pub fn highest_confirmed_root(&self) -> Slot {
|
||||||
self.slot_info.highest_confirmed_root
|
self.commitment_slots.highest_confirmed_root
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn slot_info(&self) -> CacheSlotInfo {
|
pub fn commitment_slots(&self) -> CommitmentSlots {
|
||||||
self.slot_info
|
self.commitment_slots
|
||||||
}
|
}
|
||||||
|
|
||||||
fn highest_slot_with_confirmation_count(&self, confirmation_count: usize) -> Slot {
|
fn highest_slot_with_confirmation_count(&self, confirmation_count: usize) -> Slot {
|
||||||
|
@ -112,7 +112,7 @@ impl BlockCommitmentCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.slot_info.root
|
self.commitment_slots.root
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn calculate_highest_confirmed_slot(&self) -> Slot {
|
pub fn calculate_highest_confirmed_slot(&self) -> Slot {
|
||||||
|
@ -155,7 +155,7 @@ impl BlockCommitmentCache {
|
||||||
Self {
|
Self {
|
||||||
block_commitment,
|
block_commitment,
|
||||||
total_stake: 42,
|
total_stake: 42,
|
||||||
slot_info: CacheSlotInfo {
|
commitment_slots: CommitmentSlots {
|
||||||
slot,
|
slot,
|
||||||
root,
|
root,
|
||||||
highest_confirmed_slot: root,
|
highest_confirmed_slot: root,
|
||||||
|
@ -165,16 +165,16 @@ impl BlockCommitmentCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_highest_confirmed_slot(&mut self, slot: Slot) {
|
pub fn set_highest_confirmed_slot(&mut self, slot: Slot) {
|
||||||
self.slot_info.highest_confirmed_slot = slot;
|
self.commitment_slots.highest_confirmed_slot = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_highest_confirmed_root(&mut self, root: Slot) {
|
pub fn set_highest_confirmed_root(&mut self, root: Slot) {
|
||||||
self.slot_info.highest_confirmed_root = root;
|
self.commitment_slots.highest_confirmed_root = root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Clone, Copy)]
|
#[derive(Default, Clone, Copy)]
|
||||||
pub struct CacheSlotInfo {
|
pub struct CommitmentSlots {
|
||||||
/// The slot of the bank from which all other slots were calculated.
|
/// The slot of the bank from which all other slots were calculated.
|
||||||
pub slot: Slot,
|
pub slot: Slot,
|
||||||
/// The current node root
|
/// The current node root
|
||||||
|
@ -257,7 +257,7 @@ mod tests {
|
||||||
let block_commitment_cache = BlockCommitmentCache::new(
|
let block_commitment_cache = BlockCommitmentCache::new(
|
||||||
block_commitment,
|
block_commitment,
|
||||||
total_stake,
|
total_stake,
|
||||||
CacheSlotInfo {
|
CommitmentSlots {
|
||||||
slot: bank_slot_5,
|
slot: bank_slot_5,
|
||||||
root: 0,
|
root: 0,
|
||||||
highest_confirmed_slot: 0,
|
highest_confirmed_slot: 0,
|
||||||
|
@ -275,7 +275,7 @@ mod tests {
|
||||||
let block_commitment_cache = BlockCommitmentCache::new(
|
let block_commitment_cache = BlockCommitmentCache::new(
|
||||||
block_commitment,
|
block_commitment,
|
||||||
total_stake,
|
total_stake,
|
||||||
CacheSlotInfo {
|
CommitmentSlots {
|
||||||
slot: bank_slot_5,
|
slot: bank_slot_5,
|
||||||
root: 0,
|
root: 0,
|
||||||
highest_confirmed_slot: 0,
|
highest_confirmed_slot: 0,
|
||||||
|
@ -293,7 +293,7 @@ mod tests {
|
||||||
let block_commitment_cache = BlockCommitmentCache::new(
|
let block_commitment_cache = BlockCommitmentCache::new(
|
||||||
block_commitment,
|
block_commitment,
|
||||||
total_stake,
|
total_stake,
|
||||||
CacheSlotInfo {
|
CommitmentSlots {
|
||||||
slot: bank_slot_5,
|
slot: bank_slot_5,
|
||||||
root: 0,
|
root: 0,
|
||||||
highest_confirmed_slot: 0,
|
highest_confirmed_slot: 0,
|
||||||
|
@ -311,7 +311,7 @@ mod tests {
|
||||||
let block_commitment_cache = BlockCommitmentCache::new(
|
let block_commitment_cache = BlockCommitmentCache::new(
|
||||||
block_commitment,
|
block_commitment,
|
||||||
total_stake,
|
total_stake,
|
||||||
CacheSlotInfo {
|
CommitmentSlots {
|
||||||
slot: bank_slot_5,
|
slot: bank_slot_5,
|
||||||
root: 0,
|
root: 0,
|
||||||
highest_confirmed_slot: 0,
|
highest_confirmed_slot: 0,
|
||||||
|
@ -329,7 +329,7 @@ mod tests {
|
||||||
let block_commitment_cache = BlockCommitmentCache::new(
|
let block_commitment_cache = BlockCommitmentCache::new(
|
||||||
block_commitment,
|
block_commitment,
|
||||||
total_stake,
|
total_stake,
|
||||||
CacheSlotInfo {
|
CommitmentSlots {
|
||||||
slot: bank_slot_5,
|
slot: bank_slot_5,
|
||||||
root: 0,
|
root: 0,
|
||||||
highest_confirmed_slot: 0,
|
highest_confirmed_slot: 0,
|
||||||
|
|
Loading…
Reference in New Issue