Rename MAX_ENTRY_IDS

This commit is contained in:
Michael Vines
2019-03-01 12:16:20 -08:00
parent 8ec13d557f
commit 67b6be66c8
8 changed files with 24 additions and 23 deletions

View File

@ -23,7 +23,7 @@ use solana_sdk::signature::{Keypair, Signature};
use solana_sdk::storage_program;
use solana_sdk::system_program;
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::timing::{duration_as_us, MAX_ENTRY_IDS, NUM_TICKS_PER_SECOND};
use solana_sdk::timing::{duration_as_us, MAX_RECENT_TICK_HASHES, NUM_TICKS_PER_SECOND};
use solana_sdk::token_program;
use solana_sdk::transaction::Transaction;
use solana_sdk::vote_program::{self, VoteState};
@ -594,7 +594,7 @@ impl Bank {
#[must_use]
pub fn process_transactions(&self, txs: &[Transaction]) -> Vec<Result<()>> {
let lock_results = self.lock_accounts(txs);
let results = self.load_execute_and_commit_transactions(txs, lock_results, MAX_ENTRY_IDS);
let results = self.load_execute_and_commit_transactions(txs, lock_results, MAX_RECENT_TICK_HASHES);
self.unlock_accounts(txs, &results);
results
}
@ -1201,7 +1201,7 @@ mod tests {
let lock_result = bank.lock_accounts(&pay_alice);
let results_alice =
bank.load_execute_and_commit_transactions(&pay_alice, lock_result, MAX_ENTRY_IDS);
bank.load_execute_and_commit_transactions(&pay_alice, lock_result, MAX_RECENT_TICK_HASHES);
assert_eq!(results_alice[0], Ok(()));
// try executing an interleaved transfer twice

View File

@ -1,6 +1,6 @@
use hashbrown::HashMap;
use solana_sdk::hash::Hash;
use solana_sdk::timing::{timestamp, MAX_ENTRY_IDS};
use solana_sdk::timing::{timestamp, MAX_RECENT_TICK_HASHES};
#[derive(Debug, PartialEq, Eq, Clone)]
struct HashQueueEntry {
@ -71,9 +71,9 @@ impl HashQueue {
// this clean up can be deferred until sigs gets larger
// because we verify entry.nth every place we check for validity
if self.entries.len() >= MAX_ENTRY_IDS as usize {
if self.entries.len() >= MAX_RECENT_TICK_HASHES as usize {
self.entries
.retain(|_, entry| hash_height - entry.hash_height <= MAX_ENTRY_IDS as u64);
.retain(|_, entry| hash_height - entry.hash_height <= MAX_RECENT_TICK_HASHES as u64);
}
self.entries.insert(
@ -100,7 +100,7 @@ impl HashQueue {
let mut total = 0;
for (hash_height, stake) in hashes_and_stakes.iter() {
if current_hash_height >= *hash_height
&& ((current_hash_height - hash_height) as usize) < MAX_ENTRY_IDS
&& ((current_hash_height - hash_height) as usize) < MAX_RECENT_TICK_HASHES
{
total += stake;
if total > supermajority_stake {
@ -139,7 +139,7 @@ mod tests {
fn test_reject_old_last_hash() {
let last_hash = Hash::default();
let mut entry_queue = HashQueue::default();
for i in 0..MAX_ENTRY_IDS {
for i in 0..MAX_RECENT_TICK_HASHES {
let last_hash = hash(&serialize(&i).unwrap()); // Unique hash
entry_queue.register_hash(&last_hash);
}

View File

@ -2,14 +2,13 @@ use crate::bloom::{Bloom, BloomHashIndex};
use hashbrown::HashMap;
use solana_sdk::hash::Hash;
use solana_sdk::signature::Signature;
use solana_sdk::timing::{MAX_ENTRY_IDS, NUM_TICKS_PER_SECOND};
use std::collections::VecDeque;
use std::ops::Deref;
#[cfg(test)]
use std::ops::DerefMut;
/// This cache is designed to last 1 second
const MAX_CACHE_ENTRIES: usize = MAX_ENTRY_IDS / NUM_TICKS_PER_SECOND;
/// Each cache entry is designed to span ~1 second of signatures
const MAX_CACHE_ENTRIES: usize = solana_sdk::timing::MAX_HASH_AGE_IN_SECONDS;
type FailureMap<T> = HashMap<Signature, T>;