Rename bank.id to bank.slot (#3018)
This commit is contained in:
parent
564057c812
commit
b41286919d
|
@ -98,7 +98,7 @@ pub struct Bank {
|
|||
parent_hash: Hash,
|
||||
|
||||
/// Bank fork id
|
||||
id: u64,
|
||||
slot: u64,
|
||||
|
||||
/// The number of ticks in each slot.
|
||||
ticks_per_slot: u64,
|
||||
|
@ -120,7 +120,7 @@ impl Bank {
|
|||
|
||||
pub fn new_with_paths(genesis_block: &GenesisBlock, paths: Option<String>) -> Self {
|
||||
let mut bank = Self::default();
|
||||
bank.accounts = Some(Arc::new(Accounts::new(bank.id, paths)));
|
||||
bank.accounts = Some(Arc::new(Accounts::new(bank.slot, paths)));
|
||||
bank.process_genesis_block(genesis_block);
|
||||
bank.add_builtin_programs();
|
||||
bank
|
||||
|
@ -136,12 +136,12 @@ impl Bank {
|
|||
bank.slots_per_epoch = parent.slots_per_epoch;
|
||||
bank.stakers_slot_offset = parent.stakers_slot_offset;
|
||||
|
||||
bank.id = id;
|
||||
bank.slot = id;
|
||||
bank.parent = RwLock::new(Some(parent.clone()));
|
||||
bank.parent_hash = parent.hash();
|
||||
bank.collector_id = collector_id;
|
||||
bank.accounts = Some(parent.accounts());
|
||||
bank.accounts().new_from_parent(bank.id, parent.id);
|
||||
bank.accounts().new_from_parent(bank.slot, parent.slot);
|
||||
|
||||
bank
|
||||
}
|
||||
|
@ -158,8 +158,8 @@ impl Bank {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn id(&self) -> u64 {
|
||||
self.id
|
||||
pub fn slot(&self) -> u64 {
|
||||
self.slot
|
||||
}
|
||||
|
||||
pub fn hash(&self) -> Hash {
|
||||
|
@ -187,7 +187,7 @@ impl Bank {
|
|||
let parents = self.parents();
|
||||
*self.parent.write().unwrap() = None;
|
||||
|
||||
self.accounts().squash(self.id);
|
||||
self.accounts().squash(self.slot);
|
||||
|
||||
let parent_caches: Vec<_> = parents
|
||||
.iter()
|
||||
|
@ -235,7 +235,7 @@ impl Bank {
|
|||
.unwrap();
|
||||
|
||||
self.accounts().store_slow(
|
||||
self.id,
|
||||
self.slot,
|
||||
&genesis_block.bootstrap_leader_vote_account_id,
|
||||
&bootstrap_leader_vote_account,
|
||||
);
|
||||
|
@ -252,7 +252,7 @@ impl Bank {
|
|||
|
||||
pub fn add_native_program(&self, name: &str, program_id: &Pubkey) {
|
||||
let account = native_loader::create_program_account(name);
|
||||
self.accounts().store_slow(self.id, program_id, &account);
|
||||
self.accounts().store_slow(self.slot, program_id, &account);
|
||||
}
|
||||
|
||||
fn add_builtin_programs(&self) {
|
||||
|
@ -341,11 +341,11 @@ impl Bank {
|
|||
}
|
||||
// TODO: put this assert back in
|
||||
// assert!(!self.is_frozen());
|
||||
self.accounts().lock_accounts(self.id, txs)
|
||||
self.accounts().lock_accounts(self.slot, txs)
|
||||
}
|
||||
|
||||
pub fn unlock_accounts(&self, txs: &[Transaction], results: &[Result<()>]) {
|
||||
self.accounts().unlock_accounts(self.id, txs, results)
|
||||
self.accounts().unlock_accounts(self.slot, txs, results)
|
||||
}
|
||||
|
||||
fn load_accounts(
|
||||
|
@ -355,7 +355,7 @@ impl Bank {
|
|||
error_counters: &mut ErrorCounters,
|
||||
) -> Vec<Result<(InstructionAccounts, InstructionLoaders)>> {
|
||||
self.accounts()
|
||||
.load_accounts(self.id, txs, results, error_counters)
|
||||
.load_accounts(self.slot, txs, results, error_counters)
|
||||
}
|
||||
fn check_age(
|
||||
&self,
|
||||
|
@ -463,7 +463,7 @@ impl Bank {
|
|||
}
|
||||
|
||||
self.accounts()
|
||||
.increment_transaction_count(self.id, tx_count);
|
||||
.increment_transaction_count(self.slot, tx_count);
|
||||
|
||||
inc_new_counter_info!("bank-process_transactions-txs", tx_count);
|
||||
if 0 != error_counters.last_id_not_found {
|
||||
|
@ -539,7 +539,7 @@ impl Bank {
|
|||
// assert!(!self.is_frozen());
|
||||
let now = Instant::now();
|
||||
self.accounts()
|
||||
.store_accounts(self.id, txs, executed, loaded_accounts);
|
||||
.store_accounts(self.slot, txs, executed, loaded_accounts);
|
||||
|
||||
// once committed there is no way to unroll
|
||||
let write_elapsed = now.elapsed();
|
||||
|
@ -624,7 +624,7 @@ impl Bank {
|
|||
}
|
||||
|
||||
account.tokens -= tokens;
|
||||
self.accounts().store_slow(self.id, pubkey, &account);
|
||||
self.accounts().store_slow(self.slot, pubkey, &account);
|
||||
Ok(())
|
||||
}
|
||||
None => Err(BankError::AccountNotFound),
|
||||
|
@ -634,7 +634,7 @@ impl Bank {
|
|||
pub fn deposit(&self, pubkey: &Pubkey, tokens: u64) {
|
||||
let mut account = self.get_account(pubkey).unwrap_or_default();
|
||||
account.tokens += tokens;
|
||||
self.accounts().store_slow(self.id, pubkey, &account);
|
||||
self.accounts().store_slow(self.slot, pubkey, &account);
|
||||
}
|
||||
|
||||
fn accounts(&self) -> Arc<Accounts> {
|
||||
|
@ -646,15 +646,15 @@ impl Bank {
|
|||
}
|
||||
|
||||
pub fn get_account(&self, pubkey: &Pubkey) -> Option<Account> {
|
||||
self.accounts().load_slow(self.id, pubkey)
|
||||
self.accounts().load_slow(self.slot, pubkey)
|
||||
}
|
||||
|
||||
pub fn get_account_modified_since_parent(&self, pubkey: &Pubkey) -> Option<Account> {
|
||||
self.accounts().load_slow_no_parent(self.id, pubkey)
|
||||
self.accounts().load_slow_no_parent(self.slot, pubkey)
|
||||
}
|
||||
|
||||
pub fn transaction_count(&self) -> u64 {
|
||||
self.accounts().transaction_count(self.id)
|
||||
self.accounts().transaction_count(self.slot)
|
||||
}
|
||||
|
||||
pub fn get_signature_status(&self, signature: &Signature) -> Option<Result<()>> {
|
||||
|
@ -676,11 +676,11 @@ impl Bank {
|
|||
fn hash_internal_state(&self) -> Hash {
|
||||
// If there are no accounts, return the same hash as we did before
|
||||
// checkpointing.
|
||||
if !self.accounts().has_accounts(self.id) {
|
||||
if !self.accounts().has_accounts(self.slot) {
|
||||
return self.parent_hash;
|
||||
}
|
||||
|
||||
let accounts_delta_hash = self.accounts().hash_internal_state(self.id);
|
||||
let accounts_delta_hash = self.accounts().hash_internal_state(self.slot);
|
||||
extend_and_hash(&self.parent_hash, &serialize(&accounts_delta_hash).unwrap())
|
||||
}
|
||||
|
||||
|
@ -720,7 +720,7 @@ impl Bank {
|
|||
F: Fn(&Pubkey, &VoteState) -> bool,
|
||||
{
|
||||
self.accounts()
|
||||
.get_vote_accounts(self.id)
|
||||
.get_vote_accounts(self.slot)
|
||||
.iter()
|
||||
.filter_map(|(p, account)| {
|
||||
if let Ok(vote_state) = VoteState::deserialize(&account.userdata) {
|
||||
|
|
|
@ -33,7 +33,7 @@ impl BankForks {
|
|||
let mut bank = Arc::new(bank);
|
||||
self.banks.insert(bank_id, bank.clone());
|
||||
|
||||
if bank_id > self.working_bank.id() {
|
||||
if bank_id > self.working_bank.slot() {
|
||||
self.working_bank = bank.clone()
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ impl BankForks {
|
|||
// parent if we're always calling insert()
|
||||
// when we construct a child bank
|
||||
while let Some(parent) = bank.parent() {
|
||||
self.banks.remove(&parent.id());
|
||||
self.banks.remove(&parent.slot());
|
||||
bank = parent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ where
|
|||
|
||||
let bank = banks
|
||||
.iter()
|
||||
.find(|bank| bank.id() <= slot_height)
|
||||
.find(|bank| bank.slot() <= slot_height)
|
||||
.unwrap_or_else(|| banks.last().unwrap());
|
||||
|
||||
node_stakes_extractor(bank, state_extractor)
|
||||
|
|
Loading…
Reference in New Issue