Skip to content

Commit

Permalink
Merge pull request #2 from sagar-solana/votability
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
carllin committed Apr 23, 2019
2 parents 3b8b21e + 50102a6 commit 318f5e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
19 changes: 3 additions & 16 deletions core/src/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use solana_runtime::bank::Bank;
use solana_runtime::locked_accounts_results::LockedAccountsResults;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::timing::{self, duration_as_us, MAX_RECENT_BLOCKHASHES};
use solana_sdk::transaction::{self, Transaction, TransactionError};
use solana_sdk::transaction::{self, Transaction};
use std::cmp;
use std::net::UdpSocket;
use std::sync::atomic::{AtomicBool, Ordering};
Expand Down Expand Up @@ -353,8 +353,7 @@ impl BankingStage {
.iter()
.zip(txs.iter())
.filter_map(|(r, x)| {
Self::log_tx_errors(r);
if Bank::is_tx_committable(r) {
if Bank::can_commit(r) {
Some(x.clone())
} else {
None
Expand Down Expand Up @@ -412,19 +411,6 @@ impl BankingStage {
Ok(())
}

fn log_tx_errors(result: &transaction::Result<()>) {
match result {
Err(TransactionError::InstructionError(index, err)) => {
debug!("instruction error {:?}, {:?}", index, err);
}
Err(ref e) => {
debug!("process transaction failed {:?}", e);
}

_ => (),
}
}

pub fn process_and_record_transactions(
bank: &Bank,
txs: &[Transaction],
Expand Down Expand Up @@ -662,6 +648,7 @@ mod tests {
use solana_sdk::instruction::InstructionError;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction;
use solana_sdk::transaction::TransactionError;
use std::sync::mpsc::channel;
use std::thread::sleep;

Expand Down
16 changes: 4 additions & 12 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,18 +423,14 @@ impl Bank {
self.status_cache.write().unwrap().clear_signatures();
}

pub fn is_tx_committable(result: &Result<()>) -> bool {
match result {
Ok(_) => true,
Err(TransactionError::InstructionError(_, _)) => true,
Err(_) => false,
}
pub fn can_commit(result: &Result<()>) -> bool {
result.is_ok()
}

fn update_transaction_statuses(&self, txs: &[Transaction], res: &[Result<()>]) {
let mut status_cache = self.status_cache.write().unwrap();
for (i, tx) in txs.iter().enumerate() {
if Self::is_tx_committable(&res[i]) && !tx.signatures.is_empty() {
if Self::can_commit(&res[i]) && !tx.signatures.is_empty() {
status_cache.insert(
&tx.message().recent_blockhash,
&tx.signatures[0],
Expand Down Expand Up @@ -762,11 +758,7 @@ impl Bank {
warn!("=========== FIXME: commit_transactions() working on a frozen bank! ================");
}

if executed
.iter()
.find(|res| Self::is_tx_committable(*res))
.is_some()
{
if executed.iter().any(|res| Self::can_commit(res)) {
self.is_delta.store(true, Ordering::Relaxed);
}

Expand Down

0 comments on commit 318f5e2

Please sign in to comment.