Boot BankError::MaxHeightReached

This commit is contained in:
Greg Fitzgerald 2019-02-17 15:12:06 -07:00
parent 54dfe708c1
commit 2f7911b62a
2 changed files with 6 additions and 17 deletions

View File

@ -73,9 +73,6 @@ pub enum BankError {
/// Transaction has a fee but has no signature present /// Transaction has a fee but has no signature present
MissingSignatureForFee, MissingSignatureForFee,
// Poh recorder hit the maximum tick height before leader rotation
MaxHeightReached,
} }
pub type Result<T> = result::Result<T, BankError>; pub type Result<T> = result::Result<T, BankError>;

View File

@ -128,7 +128,7 @@ impl BankingStage {
txs: &[Transaction], txs: &[Transaction],
results: &[bank::Result<()>], results: &[bank::Result<()>],
poh: &PohRecorder, poh: &PohRecorder,
) -> bank::Result<()> { ) -> Result<()> {
let processed_transactions: Vec<_> = results let processed_transactions: Vec<_> = results
.iter() .iter()
.zip(txs.iter()) .zip(txs.iter())
@ -149,15 +149,7 @@ impl BankingStage {
if !processed_transactions.is_empty() { if !processed_transactions.is_empty() {
let hash = Transaction::hash(&processed_transactions); let hash = Transaction::hash(&processed_transactions);
// record and unlock will unlock all the successfull transactions // record and unlock will unlock all the successfull transactions
poh.record(hash, processed_transactions).map_err(|e| { poh.record(hash, processed_transactions)?;
warn!("record failure: {:?}", e);
match e {
Error::PohRecorderError(PohRecorderError::MaxHeightReached) => {
BankError::MaxHeightReached
}
_ => BankError::RecordFailure,
}
})?;
} }
Ok(()) Ok(())
} }
@ -166,7 +158,7 @@ impl BankingStage {
bank: &Bank, bank: &Bank,
txs: &[Transaction], txs: &[Transaction],
poh: &PohRecorder, poh: &PohRecorder,
) -> bank::Result<()> { ) -> Result<()> {
let now = Instant::now(); let now = Instant::now();
// Once accounts are locked, other threads cannot encode transactions that will modify the // Once accounts are locked, other threads cannot encode transactions that will modify the
// same account state // same account state
@ -228,7 +220,7 @@ impl BankingStage {
&transactions[chunk_start..chunk_end], &transactions[chunk_start..chunk_end],
poh, poh,
); );
if Err(BankError::MaxHeightReached) == result { if let Err(Error::PohRecorderError(PohRecorderError::MaxHeightReached)) = result {
break; break;
} }
result?; result?;
@ -672,9 +664,9 @@ mod tests {
0, 0,
)]; )];
assert_eq!( assert_matches!(
BankingStage::process_and_record_transactions(&bank, &transactions, &poh_recorder), BankingStage::process_and_record_transactions(&bank, &transactions, &poh_recorder),
Err(BankError::MaxHeightReached) Err(Error::PohRecorderError(PohRecorderError::MaxHeightReached))
); );
assert_eq!(bank.get_balance(&pubkey), 1); assert_eq!(bank.get_balance(&pubkey), 1);