Skip to content

Commit

Permalink
chore: upgrade crossbeam-channel (#69)
Browse files Browse the repository at this point in the history
* chore: upgrade crossbeam-channel
  • Loading branch information
quake authored Dec 10, 2018
1 parent 7fef14d commit 0cd755c
Show file tree
Hide file tree
Showing 23 changed files with 146 additions and 169 deletions.
38 changes: 16 additions & 22 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ clap = { version = "2" }
serde = "1.0"
serde_derive = "1.0"
log = "0.4"
crossbeam-channel = "0.2"
crossbeam-channel = "0.3"
ckb-util = { path = "util" }
ckb-core = { path = "core" }
ckb-chain = { path = "chain" }
Expand Down
2 changes: 1 addition & 1 deletion chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ avl-merkle = { path = "../util/avl" }
bigint = { git = "https://github.com/nervosnetwork/bigint" }
lru-cache = { git = "https://github.com/nervosnetwork/lru-cache" }
fnv = "1.0.3"
crossbeam-channel = "0.2"
crossbeam-channel = "0.3"

[dev-dependencies]
env_logger = "0.6"
Expand Down
8 changes: 4 additions & 4 deletions chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ impl<CI: ChainIndex + 'static> ChainService<CI> {
thread_builder
.spawn(move || loop {
select! {
recv(receivers.process_block_receiver, msg) => match msg {
Some(Request { responder, arguments: block }) => {
responder.send(self.process_block(block));
recv(receivers.process_block_receiver) -> msg => match msg {
Ok(Request { responder, arguments: block }) => {
let _ = responder.send(self.process_block(block));
},
None => {
_ => {
error!(target: "chain", "process_block_receiver closed");
break;
},
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ hash = {path = "../util/hash"}
crypto = {path = "../util/crypto"}
ckb-time = { path = "../util/time" }
bit-vec = "0.5.0"
crossbeam-channel = "0.2"
crossbeam-channel = "0.3"
rayon = "1.0"
ckb-util = { path = "../util" }
fnv = "1.0.3"
Expand Down
4 changes: 2 additions & 2 deletions core/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ pub struct Request<A, R> {
impl<A, R> Request<A, R> {
pub fn call(sender: &Sender<Request<A, R>>, arguments: A) -> Option<R> {
let (responder, response) = channel::bounded(ONESHOT_CHANNEL_SIZE);
sender.send(Request {
let _ = sender.send(Request {
responder,
arguments,
});
response.recv()
response.recv().ok()
}
}
2 changes: 1 addition & 1 deletion miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ flatbuffers = "0.5.0"
rand = "0.6"
serde = "1.0"
serde_derive = "1.0"
crossbeam-channel = "0.2"
crossbeam-channel = "0.3"
fnv = "1.0.3"
jsonrpc = { git = "https://github.com/quake/rust-jsonrpc" }
serde_json = "1.0"
16 changes: 8 additions & 8 deletions miner/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,21 @@ impl<CI: ChainIndex + 'static> Agent<CI> {
thread_builder
.spawn(move || loop {
select! {
recv(new_uncle_receiver, msg) => match msg {
Some(uncle_block) => {
recv(new_uncle_receiver) -> msg => match msg {
Ok(uncle_block) => {
let hash = uncle_block.header().hash();
self.candidate_uncles.insert(hash, uncle_block);
}
None => {
_ => {
error!(target: "miner", "new_uncle_receiver closed");
break;
}
}
recv(receivers.get_block_template_receiver, msg) => match msg {
Some(Request { responder, arguments: (type_hash, max_tx, max_prop) }) => {
responder.send(self.get_block_template(type_hash, max_tx, max_prop));
},
recv(receivers.get_block_template_receiver) -> msg => match msg {
Ok(Request { responder, arguments: (type_hash, max_tx, max_prop) }) => {
let _ = responder.send(self.get_block_template(type_hash, max_tx, max_prop));
},
None => {
_ => {
error!(target: "miner", "get_block_template_receiver closed");
break;
},
Expand Down
2 changes: 1 addition & 1 deletion miner/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl Client {
if inner.as_ref().map_or(true, |old| is_new_job(&new, &old)) {
let mut write_guard = RwLockUpgradableReadGuard::upgrade(inner);
*write_guard = Some(new);
self.new_job_tx.send(());
let _ = self.new_job_tx.send(());
}
}
Err(e) => {
Expand Down
2 changes: 1 addition & 1 deletion miner/src/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl Miner {
fn mine_loop(&self, header: &RawHeader) -> Option<Seal> {
let mut nonce: u64 = thread_rng().gen();
loop {
if self.new_job_rx.try_recv().is_some() {
if self.new_job_rx.try_recv().is_ok() {
break None;
}
debug!(target: "miner", "mining header #{} with nonce {}", header.number(), nonce);
Expand Down
2 changes: 1 addition & 1 deletion notify/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ authors = ["Nervos Core Dev <[email protected]>"]
fnv = "1.0"
ckb-util = { path = "../util" }
ckb-core = { path = "../core" }
crossbeam-channel = "0.2"
crossbeam-channel = "0.3"
log = "0.4"
Loading

0 comments on commit 0cd755c

Please sign in to comment.