Boot sync_channel()
This is less useful now that we send Vec<Event> instead of Event.
This commit is contained in:
parent
0ee3ec86bd
commit
6967cf7f86
|
@ -9,19 +9,19 @@ use recorder::Signal;
|
|||
use result::Result;
|
||||
use signature::PublicKey;
|
||||
use std::net::{SocketAddr, UdpSocket};
|
||||
use std::sync::mpsc::SyncSender;
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::sync::Mutex;
|
||||
use transaction::Transaction;
|
||||
|
||||
pub struct AccountingStage {
|
||||
pub acc: Mutex<Accountant>,
|
||||
historian_input: Mutex<SyncSender<Signal>>,
|
||||
historian_input: Mutex<Sender<Signal>>,
|
||||
entry_info_subscribers: Mutex<Vec<SocketAddr>>,
|
||||
}
|
||||
|
||||
impl AccountingStage {
|
||||
/// Create a new Tpu that wraps the given Accountant.
|
||||
pub fn new(acc: Accountant, historian_input: SyncSender<Signal>) -> Self {
|
||||
pub fn new(acc: Accountant, historian_input: Sender<Signal>) -> Self {
|
||||
AccountingStage {
|
||||
acc: Mutex::new(acc),
|
||||
entry_info_subscribers: Mutex::new(vec![]),
|
||||
|
@ -144,7 +144,7 @@ mod tests {
|
|||
use historian::Historian;
|
||||
use mint::Mint;
|
||||
use signature::{KeyPair, KeyPairUtil};
|
||||
use std::sync::mpsc::sync_channel;
|
||||
use std::sync::mpsc::channel;
|
||||
use transaction::Transaction;
|
||||
|
||||
#[test]
|
||||
|
@ -154,7 +154,7 @@ mod tests {
|
|||
// Entry OR if the verifier tries to parallelize across multiple Entries.
|
||||
let mint = Mint::new(2);
|
||||
let acc = Accountant::new(&mint);
|
||||
let (input, event_receiver) = sync_channel(10);
|
||||
let (input, event_receiver) = channel();
|
||||
let historian = Historian::new(event_receiver, &mint.last_id(), None);
|
||||
let stage = AccountingStage::new(acc, input);
|
||||
|
||||
|
@ -201,7 +201,7 @@ mod bench {
|
|||
use rayon::prelude::*;
|
||||
use signature::{KeyPair, KeyPairUtil};
|
||||
use std::collections::HashSet;
|
||||
use std::sync::mpsc::sync_channel;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::time::Instant;
|
||||
use transaction::Transaction;
|
||||
|
||||
|
@ -245,7 +245,7 @@ mod bench {
|
|||
.map(|tr| Event::Transaction(tr))
|
||||
.collect();
|
||||
|
||||
let (input, event_receiver) = sync_channel(10);
|
||||
let (input, event_receiver) = channel();
|
||||
let historian = Historian::new(event_receiver, &mint.last_id(), None);
|
||||
let stage = AccountingStage::new(acc, input);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ use std::io::{stdin, stdout, Read};
|
|||
use std::net::UdpSocket;
|
||||
use std::process::exit;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::mpsc::sync_channel;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::sync::Arc;
|
||||
|
||||
fn print_usage(program: &str, opts: Options) {
|
||||
|
@ -116,7 +116,7 @@ fn main() {
|
|||
|
||||
eprintln!("creating networking stack...");
|
||||
|
||||
let (input, event_receiver) = sync_channel(10_000);
|
||||
let (input, event_receiver) = channel();
|
||||
let historian = Historian::new(event_receiver, &last_id, Some(1000));
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let tpu = Arc::new(Tpu::new(acc, input, historian));
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use entry::Entry;
|
||||
use hash::Hash;
|
||||
use recorder::{ExitReason, Recorder, Signal};
|
||||
use std::sync::mpsc::{sync_channel, Receiver, SyncSender, TryRecvError};
|
||||
use std::sync::mpsc::{channel, Receiver, Sender, TryRecvError};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread::{spawn, JoinHandle};
|
||||
use std::time::Instant;
|
||||
|
@ -20,7 +20,7 @@ impl Historian {
|
|||
start_hash: &Hash,
|
||||
ms_per_tick: Option<u64>,
|
||||
) -> Self {
|
||||
let (entry_sender, output) = sync_channel(10_000);
|
||||
let (entry_sender, output) = channel();
|
||||
let thread_hdl =
|
||||
Historian::create_recorder(*start_hash, ms_per_tick, event_receiver, entry_sender);
|
||||
let loutput = Arc::new(Mutex::new(output));
|
||||
|
@ -36,7 +36,7 @@ impl Historian {
|
|||
start_hash: Hash,
|
||||
ms_per_tick: Option<u64>,
|
||||
receiver: Receiver<Signal>,
|
||||
sender: SyncSender<Entry>,
|
||||
sender: Sender<Entry>,
|
||||
) -> JoinHandle<ExitReason> {
|
||||
spawn(move || {
|
||||
let mut recorder = Recorder::new(receiver, sender, start_hash);
|
||||
|
@ -66,7 +66,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_historian() {
|
||||
let (input, event_receiver) = sync_channel(10);
|
||||
let (input, event_receiver) = channel();
|
||||
let zero = Hash::default();
|
||||
let hist = Historian::new(event_receiver, &zero, None);
|
||||
|
||||
|
@ -95,7 +95,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_historian_closed_sender() {
|
||||
let (input, event_receiver) = sync_channel(10);
|
||||
let (input, event_receiver) = channel();
|
||||
let zero = Hash::default();
|
||||
let hist = Historian::new(event_receiver, &zero, None);
|
||||
drop(hist.output);
|
||||
|
@ -108,7 +108,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_ticking_historian() {
|
||||
let (input, event_receiver) = sync_channel(10);
|
||||
let (input, event_receiver) = channel();
|
||||
let zero = Hash::default();
|
||||
let hist = Historian::new(event_receiver, &zero, Some(20));
|
||||
sleep(Duration::from_millis(300));
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
use entry::{create_entry_mut, Entry};
|
||||
use event::Event;
|
||||
use hash::{hash, Hash};
|
||||
use std::sync::mpsc::{Receiver, SyncSender, TryRecvError};
|
||||
use std::sync::mpsc::{Receiver, Sender, TryRecvError};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(large_enum_variant))]
|
||||
|
@ -24,7 +24,7 @@ pub enum ExitReason {
|
|||
}
|
||||
|
||||
pub struct Recorder {
|
||||
sender: SyncSender<Entry>,
|
||||
sender: Sender<Entry>,
|
||||
receiver: Receiver<Signal>,
|
||||
last_hash: Hash,
|
||||
num_hashes: u64,
|
||||
|
@ -32,7 +32,7 @@ pub struct Recorder {
|
|||
}
|
||||
|
||||
impl Recorder {
|
||||
pub fn new(receiver: Receiver<Signal>, sender: SyncSender<Entry>, last_hash: Hash) -> Self {
|
||||
pub fn new(receiver: Receiver<Signal>, sender: Sender<Entry>, last_hash: Hash) -> Self {
|
||||
Recorder {
|
||||
receiver,
|
||||
sender,
|
||||
|
@ -88,13 +88,13 @@ impl Recorder {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use signature::{KeyPair, KeyPairUtil};
|
||||
use std::sync::mpsc::sync_channel;
|
||||
use std::sync::mpsc::channel;
|
||||
use transaction::Transaction;
|
||||
|
||||
#[test]
|
||||
fn test_events() {
|
||||
let (signal_sender, signal_receiver) = sync_channel(500);
|
||||
let (entry_sender, entry_receiver) = sync_channel(10);
|
||||
let (signal_sender, signal_receiver) = channel();
|
||||
let (entry_sender, entry_receiver) = channel();
|
||||
let zero = Hash::default();
|
||||
let mut recorder = Recorder::new(signal_receiver, entry_sender, zero);
|
||||
let alice_keypair = KeyPair::new();
|
||||
|
|
|
@ -156,7 +156,7 @@ mod tests {
|
|||
use signature::{KeyPair, KeyPairUtil};
|
||||
use std::io::sink;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::mpsc::sync_channel;
|
||||
use std::sync::mpsc::channel;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
|
@ -183,7 +183,7 @@ mod tests {
|
|||
let acc = Accountant::new(&alice);
|
||||
let bob_pubkey = KeyPair::new().pubkey();
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let (input, event_receiver) = sync_channel(10);
|
||||
let (input, event_receiver) = channel();
|
||||
let historian = Historian::new(event_receiver, &alice.last_id(), Some(30));
|
||||
let acc = Arc::new(Tpu::new(acc, input, historian));
|
||||
let threads = Tpu::serve(&acc, d, serve, skinny, gossip, exit.clone(), sink()).unwrap();
|
||||
|
@ -240,14 +240,14 @@ mod tests {
|
|||
let exit = Arc::new(AtomicBool::new(false));
|
||||
|
||||
let leader_acc = {
|
||||
let (input, event_receiver) = sync_channel(10);
|
||||
let (input, event_receiver) = channel();
|
||||
let historian = Historian::new(event_receiver, &alice.last_id(), Some(30));
|
||||
let acc = Accountant::new(&alice);
|
||||
Arc::new(Tpu::new(acc, input, historian))
|
||||
};
|
||||
|
||||
let replicant_acc = {
|
||||
let (input, event_receiver) = sync_channel(10);
|
||||
let (input, event_receiver) = channel();
|
||||
let historian = Historian::new(event_receiver, &alice.last_id(), Some(30));
|
||||
let acc = Accountant::new(&alice);
|
||||
Arc::new(Tpu::new(acc, input, historian))
|
||||
|
|
|
@ -22,7 +22,7 @@ use std::io::{Cursor, Write};
|
|||
use std::mem::size_of;
|
||||
use std::net::{SocketAddr, UdpSocket};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::mpsc::{channel, Receiver, Sender, SyncSender};
|
||||
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||
use std::sync::{Arc, Mutex, RwLock};
|
||||
use std::thread::{spawn, JoinHandle};
|
||||
use std::time::Duration;
|
||||
|
@ -39,7 +39,7 @@ type SharedTpu = Arc<Tpu>;
|
|||
|
||||
impl Tpu {
|
||||
/// Create a new Tpu that wraps the given Accountant.
|
||||
pub fn new(acc: Accountant, historian_input: SyncSender<Signal>, historian: Historian) -> Self {
|
||||
pub fn new(acc: Accountant, historian_input: Sender<Signal>, historian: Historian) -> Self {
|
||||
let accounting = AccountingStage::new(acc, historian_input);
|
||||
Tpu {
|
||||
accounting,
|
||||
|
@ -697,7 +697,6 @@ mod tests {
|
|||
use std::net::UdpSocket;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::mpsc::channel;
|
||||
use std::sync::mpsc::sync_channel;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
|
@ -739,7 +738,7 @@ mod tests {
|
|||
let acc = Accountant::new(&alice);
|
||||
let bob_pubkey = KeyPair::new().pubkey();
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let (input, event_receiver) = sync_channel(10);
|
||||
let (input, event_receiver) = channel();
|
||||
let historian = Historian::new(event_receiver, &alice.last_id(), Some(30));
|
||||
let tpu = Arc::new(Tpu::new(acc, input, historian));
|
||||
let serve_addr = leader_serve.local_addr().unwrap();
|
||||
|
@ -848,7 +847,7 @@ mod tests {
|
|||
let starting_balance = 10_000;
|
||||
let alice = Mint::new(starting_balance);
|
||||
let acc = Accountant::new(&alice);
|
||||
let (input, event_receiver) = sync_channel(10);
|
||||
let (input, event_receiver) = channel();
|
||||
let historian = Historian::new(event_receiver, &alice.last_id(), Some(30));
|
||||
let tpu = Arc::new(Tpu::new(acc, input, historian));
|
||||
let replicate_addr = target1_data.replicate_addr;
|
||||
|
|
Loading…
Reference in New Issue