Spelling and formatting
This commit is contained in:
parent
f8a67e282a
commit
b7bd38744c
|
@ -94,6 +94,7 @@ impl AccountsDB {
|
|||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn store(&mut self, pubkey: &Pubkey, account: &Account) {
|
||||
if account.tokens == 0 {
|
||||
if self.checkpoints.is_empty() {
|
||||
|
@ -107,6 +108,7 @@ impl AccountsDB {
|
|||
self.accounts.insert(pubkey.clone(), account.clone());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn store_accounts(
|
||||
&mut self,
|
||||
txs: &[Transaction],
|
||||
|
@ -125,6 +127,7 @@ impl AccountsDB {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn load_account(
|
||||
&self,
|
||||
tx: &Transaction,
|
||||
|
@ -171,6 +174,7 @@ impl AccountsDB {
|
|||
Ok(called_accounts)
|
||||
}
|
||||
}
|
||||
|
||||
fn load_accounts(
|
||||
&self,
|
||||
txs: &[Transaction],
|
||||
|
@ -187,9 +191,11 @@ impl AccountsDB {
|
|||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn increment_transaction_count(&mut self, tx_count: usize) {
|
||||
self.transaction_count += tx_count as u64
|
||||
}
|
||||
|
||||
pub fn transaction_count(&self) -> u64 {
|
||||
self.transaction_count
|
||||
}
|
||||
|
@ -200,14 +206,16 @@ impl Accounts {
|
|||
self.accounts_db.read().unwrap().keys()
|
||||
}
|
||||
|
||||
/// Slow because lock is held for 1 operation insted of many
|
||||
/// Slow because lock is held for 1 operation instead of many
|
||||
pub fn load_slow(&self, pubkey: &Pubkey) -> Option<Account> {
|
||||
self.accounts_db.read().unwrap().load(pubkey).cloned()
|
||||
}
|
||||
/// Slow because lock is held for 1 operation insted of many
|
||||
|
||||
/// Slow because lock is held for 1 operation instead of many
|
||||
pub fn store_slow(&self, pubkey: &Pubkey, account: &Account) {
|
||||
self.accounts_db.write().unwrap().store(pubkey, account)
|
||||
}
|
||||
|
||||
fn lock_account(
|
||||
account_locks: &mut HashSet<Pubkey>,
|
||||
keys: &[Pubkey],
|
||||
|
@ -236,6 +244,7 @@ impl Accounts {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hash_internal_state(&self) -> Hash {
|
||||
self.accounts_db.read().unwrap().hash_internal_state()
|
||||
}
|
||||
|
@ -303,18 +312,23 @@ impl Accounts {
|
|||
.unwrap()
|
||||
.increment_transaction_count(tx_count)
|
||||
}
|
||||
|
||||
pub fn transaction_count(&self) -> u64 {
|
||||
self.accounts_db.read().unwrap().transaction_count()
|
||||
}
|
||||
|
||||
pub fn checkpoint(&self) {
|
||||
self.accounts_db.write().unwrap().checkpoint()
|
||||
}
|
||||
|
||||
pub fn rollback(&self) {
|
||||
self.accounts_db.write().unwrap().rollback()
|
||||
}
|
||||
|
||||
pub fn purge(&self, depth: usize) {
|
||||
self.accounts_db.write().unwrap().purge(depth)
|
||||
}
|
||||
|
||||
pub fn depth(&self) -> usize {
|
||||
self.accounts_db.read().unwrap().depth()
|
||||
}
|
||||
|
@ -328,6 +342,7 @@ impl Checkpoint for AccountsDB {
|
|||
self.checkpoints
|
||||
.push_front((accounts, self.transaction_count()));
|
||||
}
|
||||
|
||||
fn rollback(&mut self) {
|
||||
let (accounts, transaction_count) = self.checkpoints.pop_front().unwrap();
|
||||
self.accounts = accounts;
|
||||
|
@ -351,6 +366,7 @@ impl Checkpoint for AccountsDB {
|
|||
merge(&mut self.accounts, &mut purge);
|
||||
}
|
||||
}
|
||||
|
||||
fn depth(&self) -> usize {
|
||||
self.checkpoints.len()
|
||||
}
|
||||
|
|
|
@ -394,6 +394,7 @@ impl Bank {
|
|||
fn lock_accounts(&self, txs: &[Transaction]) -> Vec<Result<()>> {
|
||||
self.accounts.lock_accounts(txs)
|
||||
}
|
||||
|
||||
fn unlock_accounts(&self, txs: &[Transaction], results: &[Result<()>]) {
|
||||
self.accounts.unlock_accounts(txs, results)
|
||||
}
|
||||
|
@ -410,7 +411,7 @@ impl Bank {
|
|||
let lock_time = now.elapsed();
|
||||
let now = Instant::now();
|
||||
// Use a shorter maximum age when adding transactions into the pipeline. This will reduce
|
||||
// the likelyhood of any single thread getting starved and processing old ids.
|
||||
// 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 results =
|
||||
|
@ -463,6 +464,7 @@ impl Bank {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn load_accounts(
|
||||
&self,
|
||||
txs: &[Transaction],
|
||||
|
@ -507,6 +509,7 @@ impl Bank {
|
|||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
let execution_elapsed = now.elapsed();
|
||||
let now = Instant::now();
|
||||
self.accounts
|
||||
|
@ -900,6 +903,7 @@ impl Bank {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_account_subscription(
|
||||
&self,
|
||||
bank_sub_id: Pubkey,
|
||||
|
@ -1432,7 +1436,7 @@ mod tests {
|
|||
bank.transfer(1, &mint.keypair(), bob.pubkey(), mint.last_id()),
|
||||
Err(BankError::AccountInUse)
|
||||
);
|
||||
// the second time shoudl fail as well
|
||||
// the second time should fail as well
|
||||
// this verifies that `unlock_accounts` doesn't unlock `AccountInUse` accounts
|
||||
assert_eq!(
|
||||
bank.transfer(1, &mint.keypair(), bob.pubkey(), mint.last_id()),
|
||||
|
|
Loading…
Reference in New Issue