Skip to content

Commit

Permalink
refactor: re-export crossbeam-channel
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangsoledad committed Aug 27, 2020
1 parent 90f9e4e commit a5823bb
Show file tree
Hide file tree
Showing 35 changed files with 87 additions and 63 deletions.
27 changes: 16 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ ckb-chain-spec = { path = "../spec" }
ckb-store = { path = "../store" }
ckb-verification = { path = "../verification" }
faketime = "0.2.0"
crossbeam-channel = "0.3"
ckb-stop-handler = { path = "../util/stop-handler" }
ckb-dao = { path = "../util/dao" }
ckb-proposal-table = { path = "../util/proposal-table" }
ckb-error = { path = "../error" }
ckb-app-config = { path = "../util/app-config" }
bitflags = "1.0"
ckb-rust-unstable-port = { path = "../util/rust-unstable-port" }
ckb-channel = { path = "../util/channel" }

[dev-dependencies]
ckb-test-chain-utils = { path = "../util/test-chain-utils" }
Expand Down
10 changes: 4 additions & 6 deletions chain/src/chain.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::cell::{attach_block_cell, detach_block_cell};
use crate::switch::Switch;
use ckb_channel::{self as channel, select, Sender};
use ckb_error::{Error, InternalErrorKind};
use ckb_logger::{self, debug, error, info, log_enabled, trace, warn};
use ckb_metrics::{metrics, Timer};
Expand All @@ -22,7 +23,6 @@ use ckb_verification::InvalidParentError;
use ckb_verification::{
BlockVerifier, ContextualBlockVerifier, NonContextualBlockTxsVerifier, Verifier, VerifyContext,
};
use crossbeam_channel::{self, select, Sender};
use faketime::unix_time_as_millis;
use std::collections::{HashSet, VecDeque};
use std::sync::Arc;
Expand Down Expand Up @@ -152,11 +152,9 @@ impl ChainService {
// remove `allow` tag when https://github.com/crossbeam-rs/crossbeam/issues/404 is solved
#[allow(clippy::zero_ptr, clippy::drop_copy)]
pub fn start<S: ToString>(mut self, thread_name: Option<S>) -> ChainController {
let (signal_sender, signal_receiver) =
crossbeam_channel::bounded::<()>(SIGNAL_CHANNEL_SIZE);
let (process_block_sender, process_block_receiver) =
crossbeam_channel::bounded(DEFAULT_CHANNEL_SIZE);
let (truncate_sender, truncate_receiver) = crossbeam_channel::bounded(1);
let (signal_sender, signal_receiver) = channel::bounded::<()>(SIGNAL_CHANNEL_SIZE);
let (process_block_sender, process_block_receiver) = channel::bounded(DEFAULT_CHANNEL_SIZE);
let (truncate_sender, truncate_receiver) = channel::bounded(1);

// Mainly for test: give an empty thread_name
let mut thread_builder = thread::Builder::new();
Expand Down
2 changes: 1 addition & 1 deletion ckb-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ clap = { version = "2" }
serde = { version = "1.0", features = ["derive"] }
serde_plain = "0.3.0"
toml = "0.5"
crossbeam-channel = "0.3"
ckb-app-config = { path = "../util/app-config" }
ckb-logger = { path = "../util/logger" }
ckb-logger-service = { path = "../util/logger-service" }
ckb-metrics-service = { path = "../util/metrics-service" }
ckb-util = { path = "../util" }
ckb-types = { path = "../util/types" }
ckb-channel = { path = "../util/channel" }
ckb-jsonrpc-types = { path = "../util/jsonrpc-types" }
ckb-chain = { path = "../chain" }
ckb-shared = { path = "../shared" }
Expand Down
2 changes: 1 addition & 1 deletion ckb-bin/src/subcommand/miner.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ckb_app_config::{ExitCode, MinerArgs, MinerConfig};
use ckb_channel::unbounded;
use ckb_miner::{Client, Miner};
use crossbeam_channel::unbounded;
use std::thread;

pub fn miner(args: MinerArgs) -> Result<(), ExitCode> {
Expand Down
4 changes: 2 additions & 2 deletions devtools/ci/check-cargotoml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ function search_crate() {
local depcnt=0
local grepopts="-rh"
tmpcnt=$({\
${GREP} ${grepopts} "\(^\| \)extern crate ${crate}\(::\|;\)" "${source}" \
${GREP} ${grepopts} "\(^\| \)extern crate ${crate}\(::\|;\| as \)" "${source}" \
|| true; }\
| wc -l)
depcnt=$((depcnt + tmpcnt))
tmpcnt=$({\
${GREP} ${grepopts} "\(^\| \)use ${crate}\(::\|;\)" "${source}" \
${GREP} ${grepopts} "\(^\| \)use ${crate}\(::\|;\| as \)" "${source}" \
|| true; }\
| wc -l)
depcnt=$((depcnt + tmpcnt))
Expand Down
2 changes: 1 addition & 1 deletion miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ edition = "2018"
ckb-logger = { path = "../util/logger" }
ckb-app-config = { path = "../util/app-config" }
ckb-types = { path = "../util/types" }
ckb-channel = { path = "../util/channel" }
ckb-hash = { path = "../util/hash" }
ckb-pow = { path = "../pow" }
rand = "0.6"
serde = { version = "1.0", features = ["derive"] }
crossbeam-channel = "0.3"
serde_json = "1.0"
ckb-jsonrpc-types = { path = "../util/jsonrpc-types" }
hyper = "0.12"
Expand Down
2 changes: 1 addition & 1 deletion miner/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::Work;
use ckb_app_config::MinerClientConfig;
use ckb_channel::Sender;
use ckb_jsonrpc_types::{
error::Error as RpcFail, error::ErrorCode as RpcFailCode, id::Id, params::Params,
request::MethodCall, response::Output, version::Version, Block as JsonBlock, BlockTemplate,
};
use ckb_logger::{debug, error, warn};
use ckb_stop_handler::{SignalSender, StopHandler};
use ckb_types::{packed::Block, H256};
use crossbeam_channel::Sender;
use failure::Error;
use futures::sync::{mpsc, oneshot};
use hyper::error::Error as HyperError;
Expand Down
2 changes: 1 addition & 1 deletion miner/src/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use crate::client::Client;
use crate::worker::{start_worker, WorkerController, WorkerMessage};
use crate::Work;
use ckb_app_config::MinerWorkerConfig;
use ckb_channel::{select, unbounded, Receiver};
use ckb_logger::{debug, error, info};
use ckb_pow::PowEngine;
use ckb_types::{
packed::{Byte32, Header},
prelude::*,
utilities::compact_to_target,
};
use crossbeam_channel::{select, unbounded, Receiver};
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
use lru_cache::LruCache;
use std::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion miner/src/worker/dummy.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::{Worker, WorkerMessage};
use ckb_app_config::DummyConfig;
use ckb_channel::{Receiver, Sender};
use ckb_logger::error;
use ckb_types::packed::Byte32;
use crossbeam_channel::{Receiver, Sender};
use indicatif::ProgressBar;
use rand::{
distributions::{self as dist, Distribution as _},
Expand Down
2 changes: 1 addition & 1 deletion miner/src/worker/eaglesong_simple.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use super::{Worker, WorkerMessage};
use ckb_app_config::ExtraHashFunction;
use ckb_channel::{Receiver, Sender};
use ckb_hash::blake2b_256;
use ckb_logger::{debug, error};
use ckb_pow::pow_message;
use ckb_types::{packed::Byte32, U256};
use crossbeam_channel::{Receiver, Sender};
use eaglesong::eaglesong;
use indicatif::ProgressBar;
use std::thread;
Expand Down
2 changes: 1 addition & 1 deletion miner/src/worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ mod dummy;
mod eaglesong_simple;

use ckb_app_config::MinerWorkerConfig;
use ckb_channel::{unbounded, Sender};
use ckb_logger::error;
use ckb_pow::{DummyPowEngine, EaglesongBlake2bPowEngine, EaglesongPowEngine, PowEngine};
use ckb_types::{packed::Byte32, U256};
use crossbeam_channel::{unbounded, Sender};
use dummy::Dummy;
use eaglesong_simple::EaglesongSimple;
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
Expand Down
1 change: 0 additions & 1 deletion network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ ckb-app-config = { path = "../util/app-config" }
tokio = { version = "0.2.11", features = ["time", "io-util", "tcp", "dns", "rt-threaded", "blocking", "stream"] }
tokio-util = { version = "0.3.0", features = ["codec"] }
futures = "0.3"
crossbeam-channel = "0.3"
p2p = { version="0.3.0", package="tentacle", features = ["molc"] }
faketime = "0.2.0"
lazy_static = "1.3.0"
Expand Down
8 changes: 4 additions & 4 deletions network/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use std::{
pin::Pin,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
mpsc as std_mpsc, Arc,
},
thread,
time::{Duration, Instant},
Expand Down Expand Up @@ -1036,8 +1036,8 @@ impl<T: ExitHandler> NetworkService<T> {
if let Some(name) = thread_name {
thread_builder = thread_builder.name(name.to_string());
}
let (sender, receiver) = crossbeam_channel::bounded(1);
let (start_sender, start_receiver) = crossbeam_channel::bounded(1);
let (sender, receiver) = std_mpsc::channel();
let (start_sender, start_receiver) = std_mpsc::channel();
let network_state_1 = Arc::clone(&network_state);
// Main network thread
let thread = thread_builder
Expand Down Expand Up @@ -1128,7 +1128,7 @@ impl<T: ExitHandler> NetworkService<T> {
return Err(e);
}

let stop = StopHandler::new(SignalSender::Crossbeam(sender), thread);
let stop = StopHandler::new(SignalSender::Std(sender), thread);
Ok(NetworkController {
version,
network_state,
Expand Down
2 changes: 1 addition & 1 deletion network/src/protocols/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ fn net_service_start(name: String) -> Node {
let peer_id = network_state.local_peer_id().clone();

let control = p2p_service.control().clone();
let (addr_sender, addr_receiver) = crossbeam_channel::bounded(1);
let (addr_sender, addr_receiver) = ::std::sync::mpsc::channel();

thread::spawn(move || {
let num_threads = ::std::cmp::max(num_cpus::get(), 4);
Expand Down
2 changes: 1 addition & 1 deletion notify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "MIT"
ckb-logger = { path = "../util/logger" }
ckb-app-config = { path = "../util/app-config" }
ckb-types = { path = "../util/types" }
ckb-channel = { path = "../util/channel" }
ckb-stop-handler = { path = "../util/stop-handler" }
crossbeam-channel = "0.3"

[dev-dependencies]
2 changes: 1 addition & 1 deletion notify/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use ckb_app_config::NotifyConfig;
use ckb_channel::{bounded, select, Receiver, RecvError, Sender};
use ckb_logger::{debug, error, trace};
use ckb_stop_handler::{SignalSender, StopHandler};
use ckb_types::{
core::{service::Request, BlockView},
packed::Alert,
};
use crossbeam_channel::{bounded, select, Receiver, RecvError, Sender};
use std::collections::HashMap;
use std::process::Command;
use std::thread;
Expand Down
Loading

0 comments on commit a5823bb

Please sign in to comment.