Skip to content

Commit 4edd741

Browse files
committed
Waiter accept receiver instead of returning sender
1 parent 974d789 commit 4edd741

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

src/bin/electrs.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ extern crate log;
44

55
extern crate electrs;
66

7+
use crossbeam_channel::{self as channel};
78
use error_chain::ChainedError;
89
use std::process;
910
use std::sync::{Arc, RwLock};
@@ -41,7 +42,8 @@ fn fetch_from(config: &Config, store: &Store) -> FetchFrom {
4142
}
4243

4344
fn run_server(config: Arc<Config>) -> Result<()> {
44-
let (block_hash_notify, signal) = Waiter::start();
45+
let (block_hash_notify, block_hash_receive) = channel::bounded(1);
46+
let signal = Waiter::start(block_hash_receive);
4547
let metrics = Metrics::new(config.monitoring_addr);
4648
metrics.start();
4749

src/bin/tx-fingerprint-stats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn main() {
2121
util::has_prevout,
2222
};
2323

24-
let signal = Waiter::start().1;
24+
let signal = Waiter::start(crossbeam_channel::never());
2525
let config = Config::from_args();
2626
let store = Arc::new(Store::open(&config.db_path.join("newindex"), &config));
2727

src/signal.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use bitcoin::BlockHash;
2-
use crossbeam_channel::{self as channel, after, select, Sender};
2+
use crossbeam_channel::{self as channel, after, select};
33
use std::thread;
44
use std::time::{Duration, Instant};
55

@@ -27,19 +27,14 @@ fn notify(signals: &[i32]) -> channel::Receiver<i32> {
2727
}
2828

2929
impl Waiter {
30-
pub fn start() -> (Sender<BlockHash>, Waiter) {
31-
let (block_hash_notify, block_hash_receive) = channel::bounded(1);
32-
33-
(
34-
block_hash_notify,
35-
Waiter {
36-
receiver: notify(&[
37-
SIGINT, SIGTERM,
38-
SIGUSR1, // allow external triggering (e.g. via bitcoind `blocknotify`)
39-
]),
40-
zmq_receiver: block_hash_receive,
41-
},
42-
)
30+
pub fn start(block_hash_receive: channel::Receiver<BlockHash>) -> Waiter {
31+
Waiter {
32+
receiver: notify(&[
33+
SIGINT, SIGTERM,
34+
SIGUSR1, // allow external triggering (e.g. via bitcoind `blocknotify`)
35+
]),
36+
zmq_receiver: block_hash_receive,
37+
}
4338
}
4439

4540
pub fn wait(&self, duration: Duration, accept_block_notification: bool) -> Result<()> {

tests/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl TestRunner {
124124
//tor_proxy: Option<std::net::SocketAddr>,
125125
});
126126

127-
let signal = Waiter::start().1;
127+
let signal = Waiter::start(crossbeam_channel::never());
128128
let metrics = Metrics::new(rand_available_addr());
129129
metrics.start();
130130

0 commit comments

Comments
 (0)