Better docs for banking_stage

This commit is contained in:
Greg Fitzgerald 2018-06-06 09:58:49 -06:00
parent ee44e51b30
commit 57d9fbb927
1 changed files with 15 additions and 1 deletions

View File

@ -1,4 +1,6 @@
//! The `banking_stage` processes Transaction messages. //! The `banking_stage` processes Transaction messages. It is intended to be used
//! to contruct a software pipeline. The stage uses all available CPU cores and
//! can do its processing in parallel with signature verification on the GPU.
use bank::Bank; use bank::Bank;
use bincode::deserialize; use bincode::deserialize;
@ -17,12 +19,20 @@ use std::time::Instant;
use timing; use timing;
use transaction::Transaction; use transaction::Transaction;
/// Stores the stage's thread handle and output receiver.
pub struct BankingStage { pub struct BankingStage {
/// Handle to the stage's thread.
pub thread_hdl: JoinHandle<()>, pub thread_hdl: JoinHandle<()>,
/// Output receiver for the following stage.
pub signal_receiver: Receiver<Signal>, pub signal_receiver: Receiver<Signal>,
} }
impl BankingStage { impl BankingStage {
/// Create the stage using `bank`. Exit when either `exit` is set or
/// when `verified_receiver` or the stage's output receiver is dropped.
/// Discard input packets using `packet_recycler` to minimize memory
/// allocations in a previous stage such as the `fetch_stage`.
pub fn new( pub fn new(
bank: Arc<Bank>, bank: Arc<Bank>,
exit: Arc<AtomicBool>, exit: Arc<AtomicBool>,
@ -52,6 +62,8 @@ impl BankingStage {
} }
} }
/// Convert the transactions from a blob of binary data to a vector of transactions and
/// an unused `SocketAddr` that could be used to send a response.
fn deserialize_transactions(p: &packet::Packets) -> Vec<Option<(Transaction, SocketAddr)>> { fn deserialize_transactions(p: &packet::Packets) -> Vec<Option<(Transaction, SocketAddr)>> {
p.packets p.packets
.par_iter() .par_iter()
@ -63,6 +75,8 @@ impl BankingStage {
.collect() .collect()
} }
/// Process the incoming packets and send output `Signal` messages to `signal_sender`.
/// Discard packets via `packet_recycler`.
fn process_packets( fn process_packets(
bank: Arc<Bank>, bank: Arc<Bank>,
verified_receiver: &Receiver<Vec<(SharedPackets, Vec<u8>)>>, verified_receiver: &Receiver<Vec<(SharedPackets, Vec<u8>)>>,